繁体   English   中英

将文件的路径发送到Google驱动器

[英]Sending a path of a file to google drive

我正在尝试使用硒将文件的路径发送到云应用(如google驱动器或保管箱)上的“文件上传”按钮。 我能够找到“文件上载”元素并单击它,然后“文件上载窗口”打开,因此我可以手动上载文件,但这不是我想要的。 我想做的是将路径发送到“文件上传窗口”,而无需单击“文件上传”按钮。

Box ui

如您在图片中看到的,如果我按“文件”按钮以上传文件,则会打开一个弹出窗口。 弹出窗口 我希望能够将路径直接发送到弹出窗口,而无需打开它。 有办法实现吗? 谢谢

您可以在此处使用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");
}

暂无
暂无

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

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