Selenium says element is not visible when it is with latest Firefox (ElementNotInteractableException: Element is not visible)

徘徊边缘 提交于 2019-12-10 16:25:37

问题


On our test page we have a username field and a password field as follows:

<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">

The username field is filled out by selenium, we hit a next button and the next page has the password field.

Using: Firefox version 46.0.1 and Selenium version 2.53.1

The following code was working fine:

    //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);

When I update to: Firefox version 57, and selenium 3.7.1, with geckodriver 0.19.1

The code breaks, selenium will not enter text into the password field anymore, I can manually enter the password without issue, but selenium keeps insisting that the field is not visible, even though the wait check passed right before the send keys and the username field has no issues entering the text. I get this error:

> 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)

I also tested with latest Chrome driver and it worked fine there as well. But we need to use firefox profiles, so i need this to work there. Appears to be an issue with the gecko driver, has anyone encountered this, know of a solution? I tried several approaches but it never works.

来源:https://stackoverflow.com/questions/47477659/selenium-says-element-is-not-visible-when-it-is-with-latest-firefox-elementnoti

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!