Selenium表示元素在使用最新的Firefox时不可见(ElementNotInteractableException:Element不可见)

时间:2017-11-24 17:13:13

标签: selenium firefox geckodriver

在我们的测试页面上,我们有一个用户名字段和一个密码字段,如下所示:

<input required="" placeholder="USERNAME" id="usernameIdentification" 
 class="form-control no-upper-case autoExpand textValidation" 
 autofocus="autofocus" autocapitalize="none" autocorrect="off" 
 spellcheck="false" size="20" type="text">

<input id="password" name="password" placeholder="PASSWORD" class="form-
 control no-upper-case autoExpand textValidation" required="required" 
 autofocus="" autocomplete="password" autocapitalize="none" 
 autocorrect="off" spellcheck="false" type="password" hidden="true">

用户名字段由selenium填写,我们点击下一个按钮,下一页有密码字段。

使用:Firefox版本46.0.1和Selenium版本2.53.1

以下代码工作正常:

    //Enter username
    WebElement userField = wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("usernameIdentification")));
    userField.sendkeys(username);

    //Press next button        
    wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("nextButton"))).click();

    //Fill password
    WebElement passwordField = wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("password")));
    passwordField.sendKeys(password);

当我更新到:Firefox版本57和selenium 3.7.1,使用geckodriver 0.19.1

代码中断,selenium不再将文本输入密码字段,我可以手动输入密码而不会出现问题,但selenium一直坚持认为该字段不可见,即使等待检查在发送密钥和用户名字段输入文本没有问题。我收到这个错误:

> org.openqa.selenium.ElementNotInteractableException: Element is not
> visible Build info: version: '3.7.1', revision: '8a0099a', time:
> '2017-11-06T21:01:39.354Z' System info: host: 'D2QZ7XF2', ip:
> '10.122.22.31', os.name: 'Windows 10', os.arch: 'amd64', os.version:
> '10.0', java.version: '1.8.0_151' Driver info:
> org.openqa.selenium.firefox.FirefoxDriver Capabilities
> {acceptInsecureCerts: true, browserName: firefox, browserVersion:
> 57.0, javascriptEnabled: true, moz:accessibilityChecks: false, moz:headless: false, moz:processID: 15884, moz:profile:
> C:\Users\dcollier\AppData\L..., moz:webdriverClick: false,
> pageLoadStrategy: normal, platform: XP, platformName: XP,
> platformVersion: 10.0, rotatable: false, timeouts: {implicit: 0,
> pageLoad: 300000, script: 30000}} Session ID:
> b2f9536b-23ce-4c0f-93d5-cfe46d82228d
> 
>   at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native
> Method)   at
> sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
>   at
> sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
>   at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
>   at
> org.openqa.selenium.remote.http.W3CHttpResponseCodec.createException(W3CHttpResponseCodec.java:187)
>   at
> org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:122)
>   at
> org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:49)
>   at
> org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:164)
>   at
> org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:83)
>   at
> org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:600)
>   at
> org.openqa.selenium.remote.RemoteWebElement.execute(RemoteWebElement.java:279)
>   at
> org.openqa.selenium.remote.RemoteWebElement.sendKeys(RemoteWebElement.java:100)

我还测试了最新的Chrome驱动程序,它在那里工作得很好。但我们需要使用firefox配置文件,所以我需要在那里工作。似乎是gecko驱动程序的问题,有没有人遇到过这个,知道解决方案?我试过几种方法,但它永远不会奏效。

0 个答案:

没有答案