我必须从指定的文件夹上传一个.JPG图像。Sendkeys(PATH)不起作用。机器人也不起作用。请建议我一些其他的工具,如Robot,我可以在我的maven项目中使用它的.jar文件。我必须使用网格在服务器上运行代码,所以请不要安装程序。任何外部或内部的Java类都很好。
vptzau2j1#
看看我的答案here。代码是C#的,但它概述了我在selenium测试中上传文件时使用的变通方法。注意:不需要第三方工具。
new9mtju2#
driver.findElement(By.id("uploadfile").sendkeys("path of the file");
uploading picture from system with path
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
created folder in project and uploaded imageuploading picture from project folder path
2条答案
按热度按时间vptzau2j1#
看看我的答案here。代码是C#的,但它概述了我在selenium测试中上传文件时使用的变通方法。注意:不需要第三方工具。
new9mtju2#
uploading picture from system with path
created folder in project and uploaded image
uploading picture from project folder path