Nori
Nori

Reputation: 2972

How to close dialog by Selenium?

I want close browser file window pop-up (when I upload picture to Wordpress).

enter image description here

I tried

driver.close();
driver.findElement(By.id("set-post-thumbnail")).sendKeys(Keys.ESCAPE);
driver.switchTo().alert().dismiss();

but it doesn't work. How to close dialog by Selenium?

Upvotes: 1

Views: 1232

Answers (1)

Satish Gupta
Satish Gupta

Reputation: 1467

OS Specific dialogs like File Browser can not be controlled by Selenium. It can handle only WebElements or JavaScript/Browser Alerts.

In this specific case, I think it is upload file browser. Workaround may be to pass the absolute path if some text input field is provided along with "Browse" button.

Upvotes: 1

Related Questions