0

How to close the popup modal dialog box using selenium (Java) tool for the below screenshot? Kindly Refer ans suggest

  • Is this pop up a part of DOM or it's a separate window? – Alexey R. Oct 3 '18 at 12:24
  • Just locate (take an XPath for) the Close button and click on it. Can you provide us the HTML code for Close button. – Bharat Mane Oct 3 '18 at 12:28
  • It is a part of DOM and HTML code for the close button is <button class="action-close" type="button" data-role="action"><span>X</span></button>. I have tried to close the popup using x-path. But it's not working – Anand V Oct 4 '18 at 3:34
  • Is it Windows Popup or Bootstrap Popup? – Sachintha Oct 4 '18 at 6:22
  • It is Bootstrap Popup – Anand V Oct 4 '18 at 8:50
1

I think there are two things you could try here

Alert alert = driver.switchTo().alert();
alert().dismiss();

My other theory is that if you have tried to dismiss it manually through finding an ID for the X in the corner and trying to click it, you may have to wait until the element is clickable.

WebElement element = driver.findElement(By.xpath);
if (element.isDisplayed() && element.isEnabled()) {
    element.click();
}
  • 1
    The issue is solved. It is not an alert. Your second suggestion is the solution for that. Thanks Jack – Anand V Oct 5 '18 at 6:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.