2

I'm using Selenium 3.141.59 with a Firefox driver. I have a "flex" button very visible and very clickable (according to me) but selenium doesn't seem able to click on it.

Here is the button:

 <button id="modal" class="Button Button--primary" type="submit">Ok</button>

And the error message:

org.openqa.selenium.ElementNotInteractableException: Element <button id="modal" class="Button Button--primary" type="submit"> could not be scrolled into view
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:17:03'
System info: host: 'TOTO', ip: '192.168.99.1', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_191'
Driver info: org.openqa.selenium.firefox.FirefoxDriver
Capabilities {acceptInsecureCerts: true, browserName: firefox, browserVersion: 65.0.1, javascriptEnabled: true, moz:accessibilityChecks: false, moz:geckodriverVersion: 0.23.0, moz:headless: false, moz:processID: 14000, moz:profile: C:\Users\Toto\AppData\Lo..., moz:shutdownTimeout: 60000, moz:useNonSpecCompliantPointerOrigin: false, moz:webdriverClick: true, pageLoadStrategy: normal, platform: WINDOWS, platformName: WINDOWS, platformVersion: 10.0, rotatable: false, setWindowRect: true, strictFileInteractability: false, timeouts: {implicit: 0, pageLoad: 300000, script: 30000}, unhandledPromptBehavior: dismiss and notify}
Session ID: 5c303e2c-fa05-4ee5-a1f9-56607503baf3
    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:158)
    at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:83)
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:552)
    at org.openqa.selenium.remote.RemoteWebElement.execute(RemoteWebElement.java:285)
    at org.openqa.selenium.remote.RemoteWebElement.click(RemoteWebElement.java:84)
    at myRep.Stepdefs.iClickOn(Stepdefs.java:224)
    at ✽.I click on "modal"(C:/Users/Toto/IdeaProjects/MyProject/tests/UI_test/src/test/resources/myRep/require_data.feature:26)

Since just doing:

 WebElement element = driver.findElement(By.id(id));
 element.click();

Wasn't working, I tried to add a wait but had no luck (the element never appear to be clickable):

 WebDriverWait wait = new WebDriverWait(driver, 5);
 WebElement element = driver.findElement(By.id(id));
 wait.until(ExpectedConditions.elementToBeClickable(element));
 element.click();

However, I know the element is here and is visible since my program take screenshot when a test fail. Also, I did succesfully click on the button after my program ended (and I didn't needed to scroll for that...).

As suggested here, I try to switch frame but it didn't worked either. I also tried using the js.executeScript("arguments[0].scrollIntoView(true);", element); but still no luck.

So, Any idea?


PS: I'm also aware of this question but it didn't help me either.


Additional notes:

  • The button is in a "pop-in" who appear after a click on radio-button.

  • I just notice that the DOM has a weird "shape" and I'm wondering if this could be the cause of the problem. Here is how the DOM looks like, you can notice that the footer is before the button:

    <html>
    <head>...</head>
    
    <body>
        <div id="app">
            <div>
                <header>...</header>
                <div>...</div>
                <footer>...</footer>
            </div>
        </div>
        <div>...</div>
        <div>
            <div>
                <div>...</div>
                <div>
                    <button id="modal" class="Button Button--primary" type="submit">
                        Ok
                    </button>
                </div>
            </div>
        </div>
    </body>
    
    </html>
    

1 Answer 1

2

Finally found the issue:

There was another, invisible element, with the same id. I believe that making the id unique will fix the issue.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.