File tree Expand file tree Collapse file tree 1 file changed +17
-7
lines changed
src/test/java/com/browserstack Expand file tree Collapse file tree 1 file changed +17
-7
lines changed Original file line number Diff line number Diff line change @@ -10,12 +10,22 @@ public class SingleTest extends BrowserStackTestNGTest {
10
10
11
11
@ Test
12
12
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 );
20
30
}
21
31
}
You can’t perform that action at this time.
0 commit comments