1

Im automating some flow and now I have a button "choose" that is opening the finder window where I need to select the file I want:

enter image description here

How can I automate it after clicking on "choose" so I can select a specific file to upload, lets say it's path is

/Users/username/Desktop/5.png

thanks!

Joe
  • 2,543
  • 3
  • 25
  • 49

1 Answers1

1

You can use the below code

WebElement El = driver.findElement(By.id("'fileUploadField'"));
El.sendKeys("c:\\temp\\test.txt");

make sure it is in same window if it switch to the window then you need to redirect to that window and then select that file.

Ajinkya
  • 22,324
  • 33
  • 110
  • 161
  • 1
    what is the "fileUploadField"? I only have a "choose" button that opens what you see in the image added to the question...its the finder where i need to look for the fily I want to upload @Srikrishna Nadagouda – Joe Oct 07 '15 at 08:11