|
15 | 15 |
|
16 | 16 | public class AddProduct {
|
17 | 17 | private RemoteWebDriver driver;
|
| 18 | + UtilsMethods methods = new UtilsMethods(); |
18 | 19 |
|
19 | 20 | private String Status = "failed";
|
20 | 21 |
|
21 |
| - @BeforeMethod |
22 |
| - public void setup(Method m, ITestContext ctx) throws MalformedURLException { |
23 |
| - // String username = System.getenv("LT_USERNAME") == null ? "Your LT Username" : System.getenv("LT_USERNAME"); |
24 |
| - String username = System.getProperty("LT_USERNAME"); |
25 |
| - // String authKey = System.getenv("LT_ACCESS_KEY") == null ? "Your LT AccessKey" : System.getenv("LT_ACCESS_KEY"); |
26 |
| - String authKey = System.getProperty("LT_ACCESS_KEY"); |
| 22 | + @BeforeMethod public void setup(Method m, ITestContext ctx) throws MalformedURLException { |
| 23 | + String username = System.getenv("LT_USERNAME") == null ? "Your LT Username" : System.getenv("LT_USERNAME"); |
| 24 | + String authKey = System.getenv("LT_ACCESS_KEY") == null ? "Your LT AccessKey" : System.getenv("LT_ACCESS_KEY"); |
27 | 25 | String hub = "@hub.lambdatest.com/wd/hub";
|
28 | 26 | DesiredCapabilities caps = new DesiredCapabilities();
|
29 | 27 | caps.setCapability("platform", "win10");
|
30 | 28 | caps.setCapability("browserName", "chrome");
|
31 | 29 | caps.setCapability("version", "latest");
|
32 |
| - caps.setCapability("build", System.getProperty("Build_Name") == null ? m.getName() + " - " + this.getClass().getName() : System.getProperty("Build_Name")); |
| 30 | + caps.setCapability("build", "TestNG With Java"); |
33 | 31 | caps.setCapability("name", m.getName() + " - " + this.getClass().getName());
|
34 | 32 | caps.setCapability("plugin", "git-testng");
|
35 | 33 | String[] Tags = new String[] { "Feature", "Falcon", "Severe" };
|
36 | 34 | caps.setCapability("tags", Tags);
|
37 | 35 | driver = new RemoteWebDriver(new URL("https://" + username + ":" + authKey + hub), caps);
|
38 | 36 | }
|
39 | 37 |
|
40 |
| - @Test |
41 |
| - public void addProducts() { |
| 38 | + @Test public void addProducts() { |
42 | 39 | driver.get("https://ecommerce-playground.lambdatest.io/");
|
43 |
| - driver.findElement(By.cssSelector("shop-by-category")).click(); |
| 40 | + methods.wait(driver, By.className("shop-by-category"), 30); |
| 41 | + driver.findElement(By.className("shop-by-category")).click(); |
44 | 42 | driver.findElement(By.cssSelector(".mz-pure-drawer:first-of-type .navbar-nav>li:nth-of-type(3)")).click();
|
45 |
| - driver.findElement(By.cssSelector("#container .manufacturer .mz-filter-group-content div:first-of-type div")).click(); |
| 43 | + driver.findElement(By.cssSelector("#container .manufacturer .mz-filter-group-content div:first-of-type div")) |
| 44 | + .click(); |
46 | 45 | driver.findElement(By.cssSelector(".carousel-item:first-of-type [title='HTC Touch HD']"));
|
47 |
| - driver.findElement(By.cssSelector("div[data-view_id='grid'] .product-layout:first-of-type button[title='Add to Cart']")).click(); |
| 46 | + driver.findElement( |
| 47 | + By.cssSelector("div[data-view_id='grid'] .product-layout:first-of-type button[title='Add to Cart']")) |
| 48 | + .click(); |
48 | 49 | driver.findElement(By.cssSelector("#notification-box-top .btn-primary")).click();
|
49 | 50 | driver.findElement(By.cssSelector("#content .btn-secondary")).click();
|
50 |
| - driver.findElement(By.xpath("//strong[contains(text(),'This is a dummy website for Web Automation Testing')]")).isSelected(); |
| 51 | + driver.findElement(By.xpath("//strong[contains(text(),'This is a dummy website for Web Automation Testing')]")) |
| 52 | + .isSelected(); |
51 | 53 | Status = "Passed";
|
52 | 54 | }
|
53 | 55 |
|
54 |
| - @AfterMethod |
55 |
| - public void tearDown() { |
| 56 | + @AfterMethod public void tearDown() { |
56 | 57 | driver.executeScript("lambda-status=" + Status);
|
57 | 58 | driver.quit();
|
58 | 59 | }
|
|
0 commit comments