python-3.xseleniummodal-dialogwebdriverwaitexpected-condition

ElementNotInteractableException: Message: element not interactable error sending text to Account Name field within modal dialog using Selenium Python


I want to write function which click the button then type account and submit. But the program always stop after clicked at first button, but when I look at the driver, the pop up after click button is already appear. Here is my code:

driver.implicitly_wait(10)
print("click add account")
driver.find_element(by=By.XPATH,
                    value='//*[contains(text(), "Add Account")]').click()
print("Type account...")
driver.find_element(by=By.ID, value='inp-address').send_keys(i)
time.sleep(1)
driver.execute_script("addAccount()")

This is the HTML of the first Button

<button class="btn btn-sm btn-danger" type="button" data-bs-toggle="modal" data-bs-target="#modal-add-account">Add Account</button>

pop up after click appear:

pop up after click appear

Still has error:

Still has error


Solution

  • The Account Name field is within a Modal Dialog Box.


    Solution

    To send the desired text you need to induce WebDriverWait for the element_to_be_clickable() and you can use the following locator strategy: