量角器:无法处理基于窗口的弹出窗口,以使用量角器框架浏览和上传文件

量角器:无法处理基于窗口的弹出窗口,以使用量角器框架浏览和上传文件

问题描述:

尝试使用 Protractor 框架自动将 .xml/pdf 格式文件(基于 Windows 的弹出窗口)从本地系统上传到 Web 应用程序 (Angualrjs).

Trying to automate uploading .xml/pdf format files (Windows based popup) from local system to web application (Angualrjs) using Protractor framework.

场景:浏览Chrome中的应用程序>单击上传按钮>网络应用程序弹出窗口可以找到元素>单击上传字段上的浏览按钮(此字段将被禁用,只允许单击事件打开窗口弹出窗口浏览文件)>这里我们有挑战浏览文件.

Scenario: Browser the application in Chrome> Click upload button> web app popup comes where able to locate elements > click Browse button on upload field (This field would be disabled, only click event is allowed which opens windows popup to browse files)> Here we have challenge to browse the file.

单击浏览按钮执行后> 窗口弹出显示文档位置,但我们想从桌面或项目位置浏览和上传文件.

After clicking Browse button performed> Window popup shows Documents location however we want to browse and upload the file from Desktop or from Project location.

按照下面给出的其他*参考但无法解决:如何在angularjs e2e量角器测试中上传文件

Followed other * references as given below but unable to solve: How to upload file in angularjs e2e protractor testing

我们尝试过的脚本:

iUploadConfigDefinition : (sPath) => {

  var absolutePath = path.resolve(__dirname, sPath);
    uploadInput.sendKeys(absolutePath);
}

这里不确定uploadInput"元素定位器应该是什么以及如何识别/获取弹出窗口的打开按钮.

Here not sure what should be 'uploadInput' element locator and how to recognize/fetch Open button of windows popup.

请指导.附上屏幕供参考.

Please guide. Attached the screen for reference.

在此处输入图片描述

请尝试以下解决方案:

browser.findElement(by.xpath("path of the browse button"));
browser.findElement(by.css('input[type=file]')).sendKeys('full path of the file with extension');