I have to upload a.JPG image from a specified folder. Sendkeys(PATH) is not working. The robot is also not working. Please suggest me some other tool like Robot where I can use its.jar files in my maven project. I have to run the code on the server using grid so no installers, please. Any external or internal Java class would be great.
Take a look at my answer here . The code is in C#, but it outlines the workaround I used for uploading files inside a selenium test. Note: no third-party tools were required.
-> Sendkeys() can be used to upload a file or picture using selenium and Below has given 2 ways of uploading pictures
-> We can use the below code if want to upload a file from the system
driver.findElement(By.id("uploadfile").sendkeys("path of the file");
uploading picture from system with path
-> We can use the below code if want to upload a file stored in the project folder
String projectpath = System.getProperty("user.dir"); //will retrieve the path of the project in workspace
driver.findElement(By.id("uploadfile")).sendKeys(projectpath+"\\path of the folder"); //path of the file which stored in system
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.