0

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

asked Oct 3, 2018 at 11:44
5
  • Is this pop up a part of DOM or it's a separate window? Commented Oct 3, 2018 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. Commented Oct 3, 2018 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 Commented Oct 4, 2018 at 3:34
  • Is it Windows Popup or Bootstrap Popup? Commented Oct 4, 2018 at 6:22
  • It is Bootstrap Popup Commented Oct 4, 2018 at 8:50

1 Answer 1

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();
}
answered Oct 4, 2018 at 12:53
1
  • 1
    The issue is solved. It is not an alert. Your second suggestion is the solution for that. Thanks Jack Commented Oct 5, 2018 at 6:43

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.