package zacksolutions.SeleniumPractice; import java.net.MalformedURLException; import java.net.URL; import java.time.Duration; import java.util.Properties; import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.chrome.ChromeDriver; import org.openqa.selenium.chrome.ChromeOptions; import org.openqa.selenium.firefox.FirefoxDriver; import org.openqa.selenium.firefox.FirefoxOptions; import org.openqa.selenium.remote.RemoteWebDriver; import org.testng.annotations.AfterTest; import org.testng.annotations.BeforeTest; import org.testng.annotations.Parameters; import org.testng.annotations.Test; /** * ToolsTextTest */ public class ToolsTextTest { public WebDriver driver; @BeforeTest @Parameters("Browser") public void Setup(String browser) { if (browser.equalsIgnoreCase("Chrome")) { /* ChromeOptions options = new ChromeOptions(); try { driver = new RemoteWebDriver(new URL("http://192.168.1.215:4444/wd/hub"), options); } catch (MalformedURLException e) { e.printStackTrace(); } */ System.getProperty("web-driver.chrome", "user.dir" + "/InterviewCodingQuestionsQA/Drivers/chromedriver"); driver = new ChromeDriver(); } if (browser.equalsIgnoreCase("FireFox")) { /* FirefoxOptions options = new FirefoxOptions(); try { driver = new RemoteWebDriver(new URL("http://192.168.1.215:4444/wd/hub"), options); } catch (MalformedURLException e) { // TODO: handle exception e.printStackTrace(); } */ System.getProperty("web-driver.gecko", ("user.dir") + "InterviewCodingQuestionsQA/Drivers/geckodriver"); driver = new FirefoxDriver(); } driver.get("https://demoqa.com/text-box"); driver.manage().window().maximize(); driver.manage().deleteAllCookies(); driver.manage().timeouts().implicitlyWait(Duration.ofSeconds(30)); } @Test public void TextBox() { WebElement fullName = driver.findElement(By.id("userName")); fullName.sendKeys("Desmond Hume"); WebElement email = driver.findElement(By.xpath("//input[@id='userEmail']")); email.sendKeys("desmondhume41@island.com"); WebElement address = driver.findElement(By.id("currentAddress")); address.sendKeys("4815 16 The Swan Ave # 2342"); WebElement parmanentAddress = driver.findElement(By.xpath("//textarea[@id='permanentAddress']")); parmanentAddress.sendKeys("4815 16 The Swan Ave # 2342"); driver.findElement(By.cssSelector("#submit")).click(); } @AfterTest public void tearDown() throws InterruptedException { driver.close(); } }