我正在尝试将文件的路径发送到"文件上传"云端应用程序上的按钮,如google驱动器或使用selenium的dropbox。我能够找到元素"文件上传"然后单击它,然后单击"文件上传窗口"是开放的,所以我可以手动上传文件,但这不是我想要的。我想做的是将路径发送到"文件上传窗口"无需点击"文件上传"按钮。
正如您在图片中看到的,如果我按下“文件”按钮以上传文件,则会打开一个弹出窗口。
我希望能够将路径直接发送到弹出窗口,而无需打开它。
有没有办法实现它?
感谢
答案 0 :(得分:0)
您可以在此处使用autoit在google驱动器中上传文件,点击使用selenium,然后打开上传窗口,然后添加自动代码以上传文件。
public void uploadfilechromeforgdrive(String path, String fileName) throws InterruptedException {
Logger.info("Started uploading " + fileName + " in Progress");
String dllPath = System.getProperty("user.dir") + File.separator + "src" + File.separator + "test"
+ File.separator + "resources" + File.separator + "lib" + File.separator + "jacob-1.18-x64.dll";
File file = new File(dllPath);
System.setProperty(LibraryLoader.JACOB_DLL_PATH, file.getAbsolutePath());
AutoItX x = new AutoItX();
x.winActivate("Open");
x.winWaitActive("Open");
Thread.sleep(5000);
x.controlFocus("[CLASS:#32770]", "", "Edit1");
Thread.sleep(5000);
x.ControlSetText("[CLASS:#32770]", "", "Edit1", path + fileName);
Thread.sleep(5000);
Logger.info("The sent file name " + fileName);
x.controlClick("[CLASS:#32770]", "", "Button1");
Thread.sleep(50000);
Logger.info("Started uploading " + fileName + " completed");
}