文件资源管理器未打开以上传文件

file explorer is not getting open to upload a file

这是我的 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);

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

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

E:\Patients_Data\Patient_One.xml

instead of E://Patients_Data/Patient_One.xml

接下来,

如果你还有一个输入标签和按钮标签(即按钮旁边 UI 中的文本框),请尝试调用输入标签的 sendkeys 方法来设置文件路径。

如果以上两点不能解决你的问题,那你就得用下面的方法了: 单击打开文件上传 window 的按钮,它不是 Web 组件,不受 Selenium 支持。使用任何支持原生 window popup

的第三方工具,如 Autoit、Sikuli

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