File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1- describe ( "Google's Search Functionality" , ( ) => {
2- it ( "can find search results" , async ( ) => {
3- await browser . url ( "https://www.google.com/ncr" ) ;
4- const inputForm = await $ ( "//input[@name='q']" ) ;
5- await inputForm . setValue ( [ "BrowserStack" , "Enter" ] ) ; // this helps in majority desktops
6-
7- try {
8- await browser . waitUntil ( async ( ) => ( await browser . getTitle ( ) ) . match ( / B r o w s e r S t a c k / i) , { timeout : 5000 } ) ;
9- } catch ( e ) {
10- await browser . elementSubmit ( inputForm . elementId ) ; // this helps in remaining cases, i.e. iPhone
11- }
12-
1+ describe ( "Testing with Bstackdemo" , ( ) => {
2+ it ( "add product to cart" , async ( ) => {
3+ await browser . url ( "https://bstackdemo.com/" ) ;
134 await browser . waitUntil (
14- async ( ) => ( await browser . getTitle ( ) ) . match ( / B r o w s e r S t a c k / i) ,
5+ async ( ) => ( await browser . getTitle ( ) ) . match ( / S t a c k D e m o / i) ,
156 5000 ,
167 "Title didn't match with BrowserStack"
178 ) ;
9+
10+ const productOnScreen = await $ ( '//*[@id="1"]/p' ) ;
11+ const productOnScreenText = await productOnScreen . getText ( ) ;
12+
13+ const addToCart = await $ ( '//*[@id="1"]/div[4]' ) ;
14+ await addToCart . click ( ) ;
15+
16+ const productInCart = await $ ( '//*[@id="__next"]/div/div/div[2]/div[2]/div[2]/div/div[3]/p[1]' ) ;
17+
18+ await browser . waitUntil ( async ( ) => (
19+ await productInCart . getText ( ) ) . match ( productOnScreenText ) ,
20+ { timeout : 5000 }
21+ ) ;
1822 } ) ;
1923} ) ;
You can’t perform that action at this time.
0 commit comments