-1

I am saving image from to my local system with selenium-webdriver (using Robot class):-

  1. First time it save perfectly.
  2. When I run my script second time again then it tries to save same image with the same name but windows pop appear The image with this name already exists. Do wish to save again with Ok and Cancel button. How to handle this Ok button.
Amit Singh
  • 2,698
  • 21
  • 49
Suresh Sharma
  • 186
  • 1
  • 5
  • 23
  • Another option is to just see if the file already exists. If it does, don't try to save it again. – JeffC Jul 18 '16 at 16:19

3 Answers3

-2

You can handle Windows pop-up using a 3rd party tool Auto-IT integrated with eclipse. This will consist of an script editor (where you have to write a piece of code and save as ".au3") and inspector (used to inspect the properties of the window pup-up buttons). Refer to - https://www.autoitscript.com/site/autoit/

Shyam Rajan K
  • 59
  • 1
  • 7
-2

you could also try to just send an enter press which would press whichever button is marked by default

if its more of an overlay then a real popup (like jquery or jsf in java) then you can select the buttons using xpath

Master Azazel
  • 612
  • 1
  • 12
  • 32
-2

Using selenium you can accept an Alert, try the following, I know this works in C#

IAlert alert = null;
try
{
    alert = BrowserProcess.SwitchTo().Alert();
}
catch (Exception e)
{
    //no alerts present, everything is ok
}
if (alert != null)
{
    alert.Accept();
}

In java it would be something like this:

Alert alert = driver.switchTo().alert();
alertText = alert.getText();
alert.accept();
Moe Ghafari
  • 2,227
  • 1
  • 12
  • 17