简体   繁体   中英

Python Selenium ChromeDriver error. Message: element not interactable

I'm trying to login in a URL. Getting element not interactable as error.

  • The username textbox I can get it without any issue. I do it like: driver.find_element_by_id("id_element").send_Keys("text", Keys.ENTER)
  • The password textbox I need to proceed with a different scope as I get the "element not interactable error" driver.execute_script("document.getElementById('password').value 'pass_text'")

Finally when I want to submit the button to access I get again the "element not interactable error". I tried with the two scopes but either of them don't work.

  1. driver.find_element_by_id("btn_connect").click()
  2. driver.execute_script("document.getElementById('btn_connect').click()")

HTML from the webpage

<div class="row">
    <div class="col-sm-12 form-group required">
        <label for="username">User name (or email) *</label>
        <div class="field">
            <input type="text" id="username" name="username" autocomplete="username" readonly="">
            <div class="input-group-append">
                <button id="clearUsername" onclick="goToStep1()" type="button" class="btn btn-secondary">X</button>
            </div>
        </div>
    </div>
</div>
<div class="row" id="divPasswordId">
    <div class="col-sm-12 form-group required">
        <label for="password" id="labelPwd">Password *</label>
        <div class="field">
            <input type="password" id="password" name="password" autocomplete="current-password" onchange="onChangePwd(event)" onkeyup="onKeyUpPwd(event)">
        </div>
        <div id="errorMessagesPwd" class="error-messages" style="display: none">This field is required</div>
    </div>
</div>
<div class="row action action-no-border">
    <div class="col-sm-12">
        <ul>
            <li><a onclick="lostIdentifier(getSyUrl('sy-flow-production'))">I have lost my identifier</a></li>
            <li><a onclick="lostPassword(getSyUrl('sy-flow-production'))">I lost my password</a></li>
        </ul>
        <button id="btn_next" name="btn_newt" type="button" class="btn btn-primary pull-right displayNone" onclick="checkIsSsoUser()">
            Next
        </button>
        <button id="btn_connect" name="btn_connection" type="submit" class="btn btn-primary pull-right">
            Login
        </button>
    </div>
</div>

How to fix this issue?

Thanks for any help.

Instead of using the ìd to find an element, try using the xpath .

driver.find_element_by_xpath("the_xpath_to_the_element")

In Chrome you can just use the developer tools to find your element and then right click on the element and click on copy xpath.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM