Skip to content

Commit 6d6a588

Browse files
RutvikChandlafrancisf
authored andcommitted
bstack demo
1 parent cbe1a98 commit 6d6a588

File tree

1 file changed

+17
-7
lines changed

1 file changed

+17
-7
lines changed

src/test/java/com/browserstack/SingleTest.java

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,22 @@ public class SingleTest extends BrowserStackTestNGTest {
1010

1111
@Test
1212
public void test() throws Exception {
13-
driver.get("https://www.google.com/ncr");
14-
WebElement element = driver.findElement(By.name("q"));
15-
element.sendKeys("BrowserStack");
16-
element.submit();
17-
Thread.sleep(5000);
18-
19-
Assert.assertTrue(driver.getTitle().matches("(?i)BrowserStack - Google Search"));
13+
// navigate to bstackdemo
14+
driver.get("https://www.bstackdemo.com");
15+
16+
// Check the title
17+
Assert.assertTrue(driver.getTitle().matches("StackDemo"));
18+
19+
// Save the text of the product for later verify
20+
String productOnScreenText = driver.findElement(By.xpath("//*[@id=\"1\"]/p")).getText();
21+
// Click on add to cart button
22+
driver.findElement(By.xpath("//*[@id=\"1\"]/div[4]")).click();
23+
24+
// See if the cart is opened or not
25+
Assert.assertTrue(driver.findElement(By.className("float-cart__content")).isDisplayed());
26+
27+
// Check the product inside the cart is same as of the main page
28+
String productOnCartText = driver.findElement(By.xpath("//*[@id=\"__next\"]/div/div/div[2]/div[2]/div[2]/div/div[3]/p[1]")).getText();
29+
Assert.assertEquals(productOnScreenText, productOnCartText);
2030
}
2131
}

0 commit comments

Comments
 (0)