MCPcopy Create free account
hub / github.com/LambdaTest/java-testng-selenium / TestNGTodo3

Class TestNGTodo3

src/test/java/com/lambdatest/TestNGTodo3.java:17–98  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

15import org.testng.annotations.Test;
16
17public class TestNGTodo3 {
18
19 private RemoteWebDriver driver;
20 private String Status = "failed";
21
22 @BeforeMethod
23 public void setup(Method m, ITestContext ctx) throws MalformedURLException {
24 String username = System.getenv("LT_USERNAME") == null ? "Your LT Username" : System.getenv("LT_USERNAME");
25 String authkey = System.getenv("LT_ACCESS_KEY") == null ? "Your LT AccessKey" : System.getenv("LT_ACCESS_KEY");
26
27 String hub = "@hub.lambdatest.com/wd/hub";
28
29 // ✅ W3C-compliant capabilities using ChromeOptions + LT:Options
30 MutableCapabilities ltOptions = new MutableCapabilities();
31 ltOptions.setCapability("build", "TestNG With Java");
32 ltOptions.setCapability("name", m.getName() + " - " + this.getClass().getName());
33 ltOptions.setCapability("platformName", "macOS Sonoma"); // updated OS name
34 ltOptions.setCapability("plugin", "git-testng");
35 ltOptions.setCapability("tags", new String[] { "Feature", "Tag", "Moderate" });
36
37 // ✅ Chrome-specific options
38 ChromeOptions browserOptions = new ChromeOptions();
39 browserOptions.setBrowserVersion("latest");
40 browserOptions.setCapability("LT:Options", ltOptions);
41
42 driver = new RemoteWebDriver(new URL("https://" + username + ":" + authkey + hub), browserOptions);
43 }
44
45 @Test
46 public void basicTest() throws InterruptedException {
47 System.out.println("Loading URL...");
48 driver.get("https://lambdatest.github.io/sample-todo-app/");
49 Thread.sleep(200);
50
51 System.out.println("Checking Boxes...");
52 driver.findElement(By.name("li1")).click();
53 driver.findElement(By.name("li2")).click();
54 driver.findElement(By.name("li3")).click();
55 driver.findElement(By.name("li4")).click();
56
57 System.out.println("Adding New Items...");
58 driver.findElement(By.id("sampletodotext")).sendKeys(" List Item 6");
59 driver.findElement(By.id("addbutton")).click();
60
61 driver.findElement(By.id("sampletodotext")).sendKeys(" List Item 7");
62 driver.findElement(By.id("addbutton")).click();
63
64 driver.findElement(By.id("sampletodotext")).sendKeys(" List Item 8");
65 driver.findElement(By.id("addbutton")).click();
66
67 System.out.println("Checking More Boxes...");
68 driver.findElement(By.name("li1")).click();
69 driver.findElement(By.name("li3")).click();
70 driver.findElement(By.name("li7")).click();
71 driver.findElement(By.name("li8")).click();
72
73 System.out.println("Adding Final Item...");
74 driver.findElement(By.id("sampletodotext")).sendKeys("Get Taste of Lambda and Stick to It");

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected