简体   繁体   中英

Handle windows file upload using Selenium Web Driver?

I want to upload the picture so that I can access it in my project, I have used the sendKeys("path of the picture") but by using it no action is performed, please guide me, how to use the window pop up to upload the picture or give some idea, how can I upload the picture:

WebElement Account_logo = adriver.findElement(By.xpath("//*[@id='step1']/div[1]/div/div/div/form/div[12]/div[1]/div/div/span/div[2]/div[2]"));  
Account_logo.click();
Account_logo.sendKeys("C:/Users/romit/Desktop/LOGO.jpg");

When setting the file path in your Java IDE, use the proper escape character for the back-slash.

Account_logo.sendKeys("C:\\Users\\romit\\Desktop\\LOGO.jpg");

Hope it helps !

If you want to upload a file, without having 'input' element, please refer SO Post

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM