diff --git a/parallel.xml b/parallel.xml index 21cddc0..e74de32 100644 --- a/parallel.xml +++ b/parallel.xml @@ -1,11 +1,60 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - \ No newline at end of file + + + diff --git a/src/test/java/com/lambdatest/TestNGTodo1.java b/src/test/java/com/lambdatest/TestNGTodo1.java index 62577d1..b0a367e 100644 --- a/src/test/java/com/lambdatest/TestNGTodo1.java +++ b/src/test/java/com/lambdatest/TestNGTodo1.java @@ -19,16 +19,16 @@ public class TestNGTodo1 { private String Status = "failed"; @BeforeMethod - public void setup(Method m, ITestContext ctx) throws MalformedURLException { + @org.testng.annotations.Parameters(value = {"browser", "version", "platform"}) + public void TestNGTod1(String browser, String version, String platform) { String username = System.getenv("LT_USERNAME") == null ? "Your LT Username" : System.getenv("LT_USERNAME"); String authkey = System.getenv("LT_ACCESS_KEY") == null ? "Your LT AccessKey" : System.getenv("LT_ACCESS_KEY"); - ; String hub = "@hub.lambdatest.com/wd/hub"; DesiredCapabilities caps = new DesiredCapabilities(); - caps.setCapability("platform", "MacOS Catalina"); - caps.setCapability("browserName", "Safari"); - caps.setCapability("version", "latest"); + caps.setCapability("browserName", browser); + caps.setCapability("browserVersion",version); + caps.setCapability("platform", platform); caps.setCapability("build", "TestNG With Java"); caps.setCapability("name", m.getName() + " - " + this.getClass().getName()); caps.setCapability("plugin", "git-testng"); @@ -106,4 +106,4 @@ public void tearDown() { driver.quit(); } -} \ No newline at end of file +} diff --git a/src/test/java/com/lambdatest/TestNGTodo2.java b/src/test/java/com/lambdatest/TestNGTodo2.java index 3530993..5a96eb8 100644 --- a/src/test/java/com/lambdatest/TestNGTodo2.java +++ b/src/test/java/com/lambdatest/TestNGTodo2.java @@ -19,33 +19,21 @@ public class TestNGTodo2 { private String Status = "failed"; @BeforeMethod - public void setup(Method m, ITestContext ctx) throws MalformedURLException { + @org.testng.annotations.Parameters(value = {"browser", "version", "platform"}) + public void TestNGTod2(String browser, String version, String platform) { String username = System.getenv("LT_USERNAME") == null ? "Your LT Username" : System.getenv("LT_USERNAME"); String authkey = System.getenv("LT_ACCESS_KEY") == null ? "Your LT AccessKey" : System.getenv("LT_ACCESS_KEY"); - ; - - /* - Steps to run Smart UI project (https://beta-smartui.lambdatest.com/) - Step - 1 : Change the hub URL to @beta-smartui-hub.lambdatest.com/wd/hub - Step - 2 : Add "smartUI.project": "" as a capability above - Step - 3 : Add "((JavascriptExecutor) driver).executeScript("smartui.takeScreenshot");" code wherever you need to take a screenshot - Note: for additional capabilities navigate to https://www.lambdatest.com/support/docs/test-settings-options/ - */ String hub = "@hub.lambdatest.com/wd/hub"; DesiredCapabilities caps = new DesiredCapabilities(); - caps.setCapability("platform", "Windows 10"); - caps.setCapability("browserName", "chrome"); - caps.setCapability("version", "latest"); + caps.setCapability("browserName", browser); + caps.setCapability("browserVersion",version); + caps.setCapability("platform", platform); caps.setCapability("build", "TestNG With Java"); caps.setCapability("name", m.getName() + this.getClass().getName()); caps.setCapability("plugin", "git-testng"); - /* - Enable Smart UI Project - caps.setCapability("smartUI.project", ""); - */ String[] Tags = new String[] { "Feature", "Magicleap", "Severe" }; caps.setCapability("tags", Tags); @@ -118,4 +106,4 @@ public void tearDown() { driver.quit(); } -} \ No newline at end of file +} diff --git a/src/test/java/com/lambdatest/TestNGTodo3.java b/src/test/java/com/lambdatest/TestNGTodo3.java index 632320c..36c95d2 100644 --- a/src/test/java/com/lambdatest/TestNGTodo3.java +++ b/src/test/java/com/lambdatest/TestNGTodo3.java @@ -19,16 +19,16 @@ public class TestNGTodo3 { private String Status = "failed"; @BeforeMethod - public void setup(Method m, ITestContext ctx) throws MalformedURLException { + @org.testng.annotations.Parameters(value = {"browser", "version", "platform"}) + public void TestNGTod3(String browser, String version, String platform) { String username = System.getenv("LT_USERNAME") == null ? "Your LT Username" : System.getenv("LT_USERNAME"); String authkey = System.getenv("LT_ACCESS_KEY") == null ? "Your LT AccessKey" : System.getenv("LT_ACCESS_KEY"); - ; String hub = "@hub.lambdatest.com/wd/hub"; DesiredCapabilities caps = new DesiredCapabilities(); - caps.setCapability("platform", "MacOS Catalina"); - caps.setCapability("browserName", "Chrome"); - caps.setCapability("version", "latest"); + caps.setCapability("browserName", browser); + caps.setCapability("browserVersion",version); + caps.setCapability("platform", platform); caps.setCapability("build", "TestNG With Java"); caps.setCapability("name", m.getName() + this.getClass().getName()); caps.setCapability("plugin", "git-testng"); @@ -104,4 +104,4 @@ public void tearDown() { driver.quit(); } -} \ No newline at end of file +} diff --git a/src/test/java/com/lambdatest/TestNGTodo4.java b/src/test/java/com/lambdatest/TestNGTodo4.java new file mode 100644 index 0000000..4998460 --- /dev/null +++ b/src/test/java/com/lambdatest/TestNGTodo4.java @@ -0,0 +1,109 @@ +package com.lambdatest; + +import java.lang.reflect.Method; +import java.net.MalformedURLException; +import java.net.URL; + +import org.openqa.selenium.By; +import org.openqa.selenium.remote.DesiredCapabilities; +import org.openqa.selenium.remote.RemoteWebDriver; +import org.testng.Assert; +import org.testng.ITestContext; +import org.testng.annotations.AfterMethod; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; + +public class TestNGTodo1 { + + private RemoteWebDriver driver; + private String Status = "failed"; + + @BeforeMethod + @org.testng.annotations.Parameters(value = {"browser", "version", "platform"}) + public void TestNGTod4(String browser, String version, String platform) { + String username = System.getenv("LT_USERNAME") == null ? "Your LT Username" : System.getenv("LT_USERNAME"); + String authkey = System.getenv("LT_ACCESS_KEY") == null ? "Your LT AccessKey" : System.getenv("LT_ACCESS_KEY"); + String hub = "@hub.lambdatest.com/wd/hub"; + + DesiredCapabilities caps = new DesiredCapabilities(); + caps.setCapability("browserName", browser); + caps.setCapability("browserVersion",version); + caps.setCapability("platform", platform); + caps.setCapability("build", "TestNG With Java"); + caps.setCapability("name", m.getName() + " - " + this.getClass().getName()); + caps.setCapability("plugin", "git-testng"); + + String[] Tags = new String[] { "Feature", "Falcon", "Severe" }; + caps.setCapability("tags", Tags); + + driver = new RemoteWebDriver(new URL("https://" + username + ":" + authkey + hub), caps); + + } + + @Test + public void basicTest() throws InterruptedException { + String spanText; + System.out.println("Loading Url"); + + driver.get("https://lambdatest.github.io/sample-todo-app/"); + + System.out.println("Checking Box"); + driver.findElement(By.name("li1")).click(); + + System.out.println("Checking Another Box"); + driver.findElement(By.name("li2")).click(); + + System.out.println("Checking Box"); + driver.findElement(By.name("li3")).click(); + + System.out.println("Checking Another Box"); + driver.findElement(By.name("li4")).click(); + + driver.findElement(By.id("sampletodotext")).sendKeys(" List Item 6"); + driver.findElement(By.id("addbutton")).click(); + + driver.findElement(By.id("sampletodotext")).sendKeys(" List Item 7"); + driver.findElement(By.id("addbutton")).click(); + + driver.findElement(By.id("sampletodotext")).sendKeys(" List Item 8"); + driver.findElement(By.id("addbutton")).click(); + + System.out.println("Checking Another Box"); + driver.findElement(By.name("li1")).click(); + + System.out.println("Checking Another Box"); + driver.findElement(By.name("li3")).click(); + + System.out.println("Checking Another Box"); + driver.findElement(By.name("li7")).click(); + + System.out.println("Checking Another Box"); + driver.findElement(By.name("li8")).click(); + Thread.sleep(300); + + System.out.println("Entering Text"); + driver.findElement(By.id("sampletodotext")).sendKeys("Get Taste of Lambda and Stick to It"); + + driver.findElement(By.id("addbutton")).click(); + + System.out.println("Checking Another Box"); + driver.findElement(By.name("li9")).click(); + + // Let's also assert that the todo we added is present in the list. + + spanText = driver.findElementByXPath("/html/body/div/div/div/ul/li[9]/span").getText(); + Assert.assertEquals("Get Taste of Lambda and Stick to It", spanText); + Status = "passed"; + Thread.sleep(150); + + System.out.println("TestFinished"); + + } + + @AfterMethod + public void tearDown() { + driver.executeScript("lambda-status=" + Status); + driver.quit(); + } + +} diff --git a/src/test/java/com/lambdatest/TestNGTodo5.java b/src/test/java/com/lambdatest/TestNGTodo5.java new file mode 100644 index 0000000..3b18b24 --- /dev/null +++ b/src/test/java/com/lambdatest/TestNGTodo5.java @@ -0,0 +1,110 @@ +package com.lambdatest; + +import java.lang.reflect.Method; +import java.net.MalformedURLException; +import java.net.URL; + +import org.openqa.selenium.By; +import org.openqa.selenium.remote.DesiredCapabilities; +import org.openqa.selenium.remote.RemoteWebDriver; +import org.testng.Assert; +import org.testng.ITestContext; +import org.testng.annotations.AfterMethod; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; + +public class TestNGTodo1 { + + private RemoteWebDriver driver; + private String Status = "failed"; + + @BeforeMethod + @org.testng.annotations.Parameters(value = {"browser", "version", "platform"}) + public void TestNGTod5(String browser, String version, String platform) { + String username = System.getenv("LT_USERNAME") == null ? "Your LT Username" : System.getenv("LT_USERNAME"); + String authkey = System.getenv("LT_ACCESS_KEY") == null ? "Your LT AccessKey" : System.getenv("LT_ACCESS_KEY"); + + String hub = "@hub.lambdatest.com/wd/hub"; + + DesiredCapabilities caps = new DesiredCapabilities(); + caps.setCapability("browserName", browser); + caps.setCapability("browserVersion",version); + caps.setCapability("platform", platform); + caps.setCapability("build", "TestNG With Java"); + caps.setCapability("name", m.getName() + " - " + this.getClass().getName()); + caps.setCapability("plugin", "git-testng"); + + String[] Tags = new String[] { "Feature", "Falcon", "Severe" }; + caps.setCapability("tags", Tags); + + driver = new RemoteWebDriver(new URL("https://" + username + ":" + authkey + hub), caps); + + } + + @Test + public void basicTest() throws InterruptedException { + String spanText; + System.out.println("Loading Url"); + + driver.get("https://lambdatest.github.io/sample-todo-app/"); + + System.out.println("Checking Box"); + driver.findElement(By.name("li1")).click(); + + System.out.println("Checking Another Box"); + driver.findElement(By.name("li2")).click(); + + System.out.println("Checking Box"); + driver.findElement(By.name("li3")).click(); + + System.out.println("Checking Another Box"); + driver.findElement(By.name("li4")).click(); + + driver.findElement(By.id("sampletodotext")).sendKeys(" List Item 6"); + driver.findElement(By.id("addbutton")).click(); + + driver.findElement(By.id("sampletodotext")).sendKeys(" List Item 7"); + driver.findElement(By.id("addbutton")).click(); + + driver.findElement(By.id("sampletodotext")).sendKeys(" List Item 8"); + driver.findElement(By.id("addbutton")).click(); + + System.out.println("Checking Another Box"); + driver.findElement(By.name("li1")).click(); + + System.out.println("Checking Another Box"); + driver.findElement(By.name("li3")).click(); + + System.out.println("Checking Another Box"); + driver.findElement(By.name("li7")).click(); + + System.out.println("Checking Another Box"); + driver.findElement(By.name("li8")).click(); + Thread.sleep(300); + + System.out.println("Entering Text"); + driver.findElement(By.id("sampletodotext")).sendKeys("Get Taste of Lambda and Stick to It"); + + driver.findElement(By.id("addbutton")).click(); + + System.out.println("Checking Another Box"); + driver.findElement(By.name("li9")).click(); + + // Let's also assert that the todo we added is present in the list. + + spanText = driver.findElementByXPath("/html/body/div/div/div/ul/li[9]/span").getText(); + Assert.assertEquals("Get Taste of Lambda and Stick to It", spanText); + Status = "passed"; + Thread.sleep(150); + + System.out.println("TestFinished"); + + } + + @AfterMethod + public void tearDown() { + driver.executeScript("lambda-status=" + Status); + driver.quit(); + } + +} diff --git a/src/test/java/com/lambdatest/TestNGTodo6.java b/src/test/java/com/lambdatest/TestNGTodo6.java new file mode 100644 index 0000000..5de38e9 --- /dev/null +++ b/src/test/java/com/lambdatest/TestNGTodo6.java @@ -0,0 +1,109 @@ +package com.lambdatest; + +import java.lang.reflect.Method; +import java.net.MalformedURLException; +import java.net.URL; + +import org.openqa.selenium.By; +import org.openqa.selenium.remote.DesiredCapabilities; +import org.openqa.selenium.remote.RemoteWebDriver; +import org.testng.Assert; +import org.testng.ITestContext; +import org.testng.annotations.AfterMethod; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; + +public class TestNGTodo1 { + + private RemoteWebDriver driver; + private String Status = "failed"; + + @BeforeMethod + @org.testng.annotations.Parameters(value = {"browser", "version", "platform"}) + public void TestNGTod1(String browser, String version, String platform) { + String username = System.getenv("LT_USERNAME") == null ? "Your LT Username" : System.getenv("LT_USERNAME"); + String authkey = System.getenv("LT_ACCESS_KEY") == null ? "Your LT AccessKey" : System.getenv("LT_ACCESS_KEY"); + + String hub = "@hub.lambdatest.com/wd/hub"; + + DesiredCapabilities caps = new DesiredCapabilities(); + caps.setCapability("browserName", browser); + caps.setCapability("browserVersion",version); + caps.setCapability("platform", platform); + caps.setCapability("name", m.getName() + " - " + this.getClass().getName()); + caps.setCapability("plugin", "git-testng"); + + String[] Tags = new String[] { "Feature", "Falcon", "Severe" }; + caps.setCapability("tags", Tags); + + driver = new RemoteWebDriver(new URL("https://" + username + ":" + authkey + hub), caps); + + } + + @Test + public void basicTest() throws InterruptedException { + String spanText; + System.out.println("Loading Url"); + + driver.get("https://lambdatest.github.io/sample-todo-app/"); + + System.out.println("Checking Box"); + driver.findElement(By.name("li1")).click(); + + System.out.println("Checking Another Box"); + driver.findElement(By.name("li2")).click(); + + System.out.println("Checking Box"); + driver.findElement(By.name("li3")).click(); + + System.out.println("Checking Another Box"); + driver.findElement(By.name("li4")).click(); + + driver.findElement(By.id("sampletodotext")).sendKeys(" List Item 6"); + driver.findElement(By.id("addbutton")).click(); + + driver.findElement(By.id("sampletodotext")).sendKeys(" List Item 7"); + driver.findElement(By.id("addbutton")).click(); + + driver.findElement(By.id("sampletodotext")).sendKeys(" List Item 8"); + driver.findElement(By.id("addbutton")).click(); + + System.out.println("Checking Another Box"); + driver.findElement(By.name("li1")).click(); + + System.out.println("Checking Another Box"); + driver.findElement(By.name("li3")).click(); + + System.out.println("Checking Another Box"); + driver.findElement(By.name("li7")).click(); + + System.out.println("Checking Another Box"); + driver.findElement(By.name("li8")).click(); + Thread.sleep(300); + + System.out.println("Entering Text"); + driver.findElement(By.id("sampletodotext")).sendKeys("Get Taste of Lambda and Stick to It"); + + driver.findElement(By.id("addbutton")).click(); + + System.out.println("Checking Another Box"); + driver.findElement(By.name("li9")).click(); + + // Let's also assert that the todo we added is present in the list. + + spanText = driver.findElementByXPath("/html/body/div/div/div/ul/li[9]/span").getText(); + Assert.assertEquals("Get Taste of Lambda and Stick to It", spanText); + Status = "passed"; + Thread.sleep(150); + + System.out.println("TestFinished"); + + } + + @AfterMethod + public void tearDown() { + driver.executeScript("lambda-status=" + Status); + driver.quit(); + } + +} diff --git a/src/test/java/com/lambdatest/sel4.java b/src/test/java/com/lambdatest/sel4.java new file mode 100644 index 0000000..8eced5e --- /dev/null +++ b/src/test/java/com/lambdatest/sel4.java @@ -0,0 +1,106 @@ +package com.lambdatest; + +import java.lang.reflect.Method; +import java.net.MalformedURLException; +import java.net.URL; +import java.util.HashMap; +import org.openqa.selenium.By; +import org.openqa.selenium.remote.DesiredCapabilities; +import org.openqa.selenium.remote.RemoteWebDriver; +import org.testng.Assert; +import org.testng.ITestContext; +import org.testng.annotations.AfterMethod; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; + +public class sel4 { + + private RemoteWebDriver driver; + private String Status = "failed"; + + @BeforeMethod + public void setup(Method m, ITestContext ctx) throws MalformedURLException { + String username = System.getenv("LT_USERNAME") == null ? "Your LT Username" : System.getenv("LT_USERNAME"); + String authkey = System.getenv("LT_ACCESS_KEY") == null ? "Your LT AccessKey" : System.getenv("LT_ACCESS_KEY"); + ; + String hub = "@hub.lambdatest.com/wd/hub"; + + DesiredCapabilities capabilities = new DesiredCapabilities(); + HashMap ltOptions = new HashMap(); + ltOptions.put("w3c", true); + ltOptions.put("browserName", "Chrome"); + ltOptions.put("platformName", "Windows 11"); + ltOptions.put("browserVersion", "110"); + capabilities.setCapability("lt:options", ltOptions); + + + + driver = new RemoteWebDriver(new URL("https://" + username + ":" + authkey + hub), capabilities); + } + + @Test + public void basicTest() throws InterruptedException { + String spanText; + System.out.println("Loading Url"); + Thread.sleep(100); + driver.get("https://lambdatest.github.io/sample-todo-app/"); + + System.out.println("Checking Box"); + driver.findElement(By.name("li1")).click(); + + System.out.println("Checking Another Box"); + driver.findElement(By.name("li2")).click(); + + System.out.println("Checking Box"); + driver.findElement(By.name("li3")).click(); + + System.out.println("Checking Another Box"); + driver.findElement(By.name("li4")).click(); + + driver.findElement(By.id("sampletodotext")).sendKeys(" List Item 6"); + driver.findElement(By.id("addbutton")).click(); + + driver.findElement(By.id("sampletodotext")).sendKeys(" List Item 7"); + driver.findElement(By.id("addbutton")).click(); + + driver.findElement(By.id("sampletodotext")).sendKeys(" List Item 8"); + driver.findElement(By.id("addbutton")).click(); + + System.out.println("Checking Another Box"); + driver.findElement(By.name("li1")).click(); + + System.out.println("Checking Another Box"); + driver.findElement(By.name("li3")).click(); + + System.out.println("Checking Another Box"); + driver.findElement(By.name("li7")).click(); + + System.out.println("Checking Another Box"); + driver.findElement(By.name("li8")).click(); + + System.out.println("Entering Text"); + driver.findElement(By.id("sampletodotext")).sendKeys("Get Taste of Lambda and Stick to It"); + + driver.findElement(By.id("addbutton")).click(); + + System.out.println("Checking Another Box"); + driver.findElement(By.name("li9")).click(); + + // Let's also assert that the todo we added is present in the list. + + spanText = driver.findElementByXPath("/html/body/div/div/div/ul/li[9]/span").getText(); + Assert.assertEquals("Get Taste of Lambda and Stick to It", spanText); + Status = "passed"; + Thread.sleep(800); + + System.out.println("TestFinished"); + + } + + @AfterMethod + public void tearDown() { + driver.executeScript("lambda-status=" + Status); + driver.quit(); + } + +}