我正在使用量角器版本5.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);
UI代码为
<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中解决此问题。谢谢!
答案 0 :(得分:0)
以下代码在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);
答案 1 :(得分:0)
directConnect:否,
{browserName:'firefox','moz:webdriverClick':false}
设置这些属性,然后在您的配置文件中输入代码,即可解决该问题。