由于火狐浏览器中的错误"WebDriverError: Element is not reachable by keyboard"无法上传文件



我正在使用量角器版本5.2.2.2.,geckodriver-v0.21.0和Firefox浏览器版本61.当我尝试在Firefox浏览器中运行量角器脚本时,它将错误显示为

"WebDriverError:Element  <input id="logo" class="frx-input-file" name="logo" 
type="file">is not reachable by keyboard.
Build info: version: '3.13.0', revision: '2f0d292', time: '2018-06-25T15:
32:19.891Z'
System info: host: 'CS-COK-DEV-039', os.name: 'Windows 8.1', os.arch: 
'amd64', os.version: '6.3', java.version: '1.8.0_60'
Driver info: driver.version: unknown".   

量角器代码是

var path = require('path');
var fileToUpload = "F://images/f2.jpg";
var absolutePath = path.resolve(__dirname, fileToUpload);
element(by.css('.frx-form-section-container .frx-client-logo-field .frx-input-file')).sendKeys(absolutePath);

用户界面代码是

<div _ngcontent-c6="" class="frx-form-input-field-container frx-client-logo- 
field">
<label _ngcontent-c6="" class="frx-input-file-label" for="logo">Upload 
logo</label>
<br _ngcontent-c6="">
<span _ngcontent-c6="" class="frx-input-file-caption" for="logo">Will be 
used on the templates and letters</span>
<input _ngcontent-c6="" accept=".jpg, .jpeg, .gif .JPG, .JPEG, .GIF, .BMP 
,.bmp" class="frx-input-file" id="logo" multiple="false" name="logo" 
type="file">
</div>

相同的量角器脚本在 chrome 和 IE 浏览器中成功运行。我们如何在火狐中解决这个问题.提前感谢

下面的代码在Firefox,Chrome和IE中成功地为我工作。

var path = require('path');
//use your file's path
var fileToUpload = "../files/helthplan.png";
var absolutePath = path.resolve(__dirname, fileToUpload);
//use your application's locator for upload input file.
var fileElem = element(by.css(".frx-form-section-container .frx-client-logo-field .frx- input-file"));
browser.executeScript("arguments[0].style.display = 'inline';", 
fileElem.getWebElement());
element(by.css('input[type="file"]')).sendKeys(absolutePath);

directConnect: false,

{ browserName: 'firefox', 'moz:webdriverClick': false }

设置这些属性 在此处输入代码 配置文件 将解决问题。

最新更新