Closed Pearlking311 closed 9 months ago
Similar example
Browser: Chrome URL: https://www.demoblaze.com/prod.html?idp_=1# Action: Add product to cart
Hi @Pearlking311 I checked the Selenium NodeJS documentation and this should do the trick:
await context.selenium.driver.switchTo().alert().accept();
Hi @soulgalore , It doesn't works for me. Attaching the script for your reference. Add.txt
Error: ERROR: Failed waiting on page to finished loading, timed out after 120000 ms UnexpectedAlertOpenError: unexpected alert open: {Alert text : Product added} (Session info: chrome=121.0.6167.161) (Session info: chrome=121.0.6167.161) at Object.throwDecodedError (C:\Users\mjs\AppData\Roaming\npm\node_modules\sitespeed.io\node_modules\selenium-webdriver\lib\error.js:524:15) at parseHttpResponse (C:\Users\mjs\AppData\Roaming\npm\node_modules\sitespeed.io\node_modules\selenium-webdriver\lib\http.js:601:13) at Executor.execute (C:\Users\mjs\AppData\Roaming\npm\node_modules\sitespeed.io\node_modules\selenium-webdriver\lib\http.js:529:28) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) at async Driver.execute (C:\Users\mjs\AppData\Roaming\npm\node_modules\sitespeed.io\node_modules\selenium-webdriver\lib\webdriver.js:745:17)
It works when I tested on your example on https://www.demoblaze.com/prod.html?idp_=1# ? Maybe it's something else, can you share the full example then so I can help you?
Hi @soulgalore I have attached full script on above comments as txt file. Attaching here also for your reference Add.txt
Hi @Pearlking311 so I made one change when you click and it works for me, hope it works for you too.
// await commands.click.byXpathAndWait('//a[text()="Add to cart"]');
await commands.mouse.singleClick.byLinkText('Add to cart');
The ...AndClick means that it's waiting for a page navigation. When I try debug scripts I try to follow these things: https://www.sitespeed.io/documentation/sitespeed.io/scripting/tutorial-07-Debugging-Scripts.html
@soulgalore Thanks for your support. It works. Closing the issue.
Your question
Need help on handling Alert box. I have tried with
const Alert = seleniumWebdriver.Alert; await Alert.accept();
But getting below mentioned error.
ERROR: Failed waiting on page to finished loading, timed out after 120000 ms UnexpectedAlertOpenError: unexpected alert open: {Alert text : Are you sure you want to delete 1 record(s)?}
(Session info: chrome=121.0.6167.161)
(Session info: chrome=121.0.6167.161)
[2024-02-13 16:44:55] ERROR: UrlLoadError: Failed waiting on page to finished loading, timed out after 120000 ms