How to close popup in Selenium using Java.?

341 Views Asked by At

I am unable to close popup (Find attached screenshot) in the website>> https://www.lambdatest.com/selenium-playground

enter image description here

I tried closing the element by using locators but I got element not interactable error and also I tried with getWindow Handle method but no use. Please help me on this.

3

There are 3 best solutions below

1
Narendra Kulkarni On

Below code used for alert/pop

Thread.sleep(3000); driver.switch().to.alert().dismiss()

Try to use above one.

0
Razvan On

You need to click on X button. Here is the locator: css -> #exit_popup_close

0
Keerthana J On

You need to find the close button and click as follows.

WebElement alertBox = driver.findElement(By.xpath("//*@id='exit_popup_close']"));
alertBox.click();