文件资源管理器无法打开以上载文件

qmelpv7a  于 2021-07-12  发布在  Java
关注(0)|答案(1)|浏览(306)

这是我的html:

<button ng-if="!isIE()" id="UploadedFileBtn" data-ng-click="SelectFile()" title="Browse" text="Browse" style="padding-bottom :5px" class="ng-scope">
                        <mosaic-icon name="upload" width="20" height="20" class=""><svg class="icon" width="20" height="20"><use xlink:href="#mosaic_icon_upload"></use></svg></mosaic-icon>
                    </button>

一个按钮用于打开文件资源管理器。这是我的java代码:

public void depositSingleDocument(String path, String doctype) throws InterruptedException
    {
        DriverOperations.getWhenElementVisible(upload);
        upload.sendKeys(path);

我无法打开文件资源管理器,因此无法传递文件路径。

yruzcnhs

yruzcnhs1#

首先,确保文件路径没有引起问题。下面的路径示例:

E:\\Patients_Data\\Patient_One.xml

instead of E://Patients_Data/Patient_One.xml

接下来,
如果您还有一个输入标记和按钮标记(即ui中按钮旁边的文本框),请尝试调用输入标记的sendkeys方法来设置文件路径。
如果以上两点不能解决您的问题,那么您必须采用以下方法:单击一个按钮打开文件上载窗口,该窗口不是web组件,也不受selenium支持。使用任何第三方工具,如autoit,sikuli,它支持本机窗口弹出

public void depositSingleDocument(String path, String doctype) throws InterruptedException
   {
       DriverOperations.getWhenElementVisible(upload);
       upload.click();

相关问题