'Is there any way to handle java Script based Pop up in selenium (Java) without using alert.dismiss method?
Image attached I have used Alert.dismiss(); but it is not working. I want to click on cancel button. Is there any other way to handle. I have tried considering this pop up as window.
Please find image in attachment.
Solution 1:[1]
Try to click on the cancel button:
WebElement cancelBtn = driver.findElementByXpath("//button[contains(text(),'cancel')]");
cancelBtn.click();
If this doesn't work, see if the pop-up is inside an Iframe. If so switch to the Iframe and then look for the cancel button.
driver.switchToIframe(0);
// or
driver.switchToIfrmae("IDOfTheIframe");
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Tal Angel |
