From 721e95641012470e8b54398ce05fa7f3997352ac Mon Sep 17 00:00:00 2001 From: Sami Date: Wed, 6 Nov 2024 23:01:09 -0500 Subject: [PATCH] fix Diff: DemoQA --- .idea/codeStyles/Project.xml | 7 ++ .idea/codeStyles/codeStyleConfig.xml | 5 ++ .idea/git_toolbox_blame.xml | 6 ++ .idea/misc.xml | 2 +- .../SeleniumPractice/ToolsTextTest.java | 75 +++++++++++++++++++ testng.xml | 16 ++-- 6 files changed, 102 insertions(+), 9 deletions(-) create mode 100644 .idea/codeStyles/Project.xml create mode 100644 .idea/codeStyles/codeStyleConfig.xml create mode 100644 .idea/git_toolbox_blame.xml create mode 100644 src/test/java/zacksolutions/SeleniumPractice/ToolsTextTest.java diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml new file mode 100644 index 0000000..919ce1f --- /dev/null +++ b/.idea/codeStyles/Project.xml @@ -0,0 +1,7 @@ + + + + + + \ No newline at end of file diff --git a/.idea/codeStyles/codeStyleConfig.xml b/.idea/codeStyles/codeStyleConfig.xml new file mode 100644 index 0000000..a55e7a1 --- /dev/null +++ b/.idea/codeStyles/codeStyleConfig.xml @@ -0,0 +1,5 @@ + + + + \ No newline at end of file diff --git a/.idea/git_toolbox_blame.xml b/.idea/git_toolbox_blame.xml new file mode 100644 index 0000000..7dc1249 --- /dev/null +++ b/.idea/git_toolbox_blame.xml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml index 36cdbc1..e122dea 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -8,7 +8,7 @@ - + \ No newline at end of file diff --git a/src/test/java/zacksolutions/SeleniumPractice/ToolsTextTest.java b/src/test/java/zacksolutions/SeleniumPractice/ToolsTextTest.java new file mode 100644 index 0000000..b19a70f --- /dev/null +++ b/src/test/java/zacksolutions/SeleniumPractice/ToolsTextTest.java @@ -0,0 +1,75 @@ +package zacksolutions.SeleniumPractice; + +import java.net.MalformedURLException; +import java.net.URL; +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"); + } + + @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 { + Thread.sleep(5000); + driver.close(); + } +} diff --git a/testng.xml b/testng.xml index 480c605..c322c97 100644 --- a/testng.xml +++ b/testng.xml @@ -1,22 +1,22 @@ - - + + - + - + - - + + - + - +