简体   繁体   English

使用Selenium Web Driver处理Windows文件上传?

[英]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: 我想上传图片,以便可以在项目中访问它,我已经使用了sendKeys("path of 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. 在Java IDE中设置文件路径时,请对反斜杠使用正确的转义符。

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 如果您要上传文件而没有“ input”元素,请参阅SO Post

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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