gpt4 book ai didi

java - 将文件的路径发送到谷歌驱动器

转载 作者:太空宇宙 更新时间:2023-11-04 11:14:11 27 4
gpt4 key购买 nike

我正在尝试使用 selenium 将文件路径发送到云应用程序(例如 Google Drive 或 Dropbox)上的“文件上传”按钮。我能够找到“文件上传”元素并单击它,然后“文件上传窗口”打开,这样我就可以手动上传文件,但这不是我想要的。我想做的是将路径发送到“文件上传窗口”,而不需要单击“文件上传”按钮。

box ui

如图所示,如果我按"file"按钮上传文件,则会打开一个弹出窗口。 popup window我希望能够将路径直接发送到弹出窗口,而不需要打开它。有办法实现吗?谢谢

最佳答案

您可以在此处使用 autoit 来上传 Google Drive 中的文件,单击使用 selenium,上传窗口打开后添加 autoit 代码来上传文件。

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");
}

关于java - 将文件的路径发送到谷歌驱动器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45669911/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com