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.– Alexey R.2018年10月03日 12:24:22 +00:00Commented 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.Bharat Mane– Bharat Mane ♦2018年10月03日 12:28:10 +00:00Commented 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 workingAnand V– Anand V2018年10月04日 03:34:58 +00:00Commented Oct 4, 2018 at 3:34
-
Is it Windows Popup or Bootstrap Popup?Sachintha– Sachintha2018年10月04日 06:22:17 +00:00Commented Oct 4, 2018 at 6:22
-
It is Bootstrap PopupAnand V– Anand V2018年10月04日 08:50:58 +00:00Commented Oct 4, 2018 at 8:50
1 Answer 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
-
1The issue is solved. It is not an alert. Your second suggestion is the solution for that. Thanks JackAnand V– Anand V2018年10月05日 06:43:28 +00:00Commented Oct 5, 2018 at 6:43