0

I am trying to fill in a registration form and click submit. But Selenium says the Registration button is not actionable. I have tried using actionchains and a couple of other techniques but generally get the same error.

selenium.common.exceptions.ElementNotInteractableException: Message: element not interactable

My code...

driver.get('https://discover.workato.com/automate-2022/p/1?utm_source=Automate+2022&utm_medium=employee+referral&utm_campaign=MCoblentz')
time.sleep(3)

first_name = driver.find_element_by_xpath('//*[@id="FirstName"]')
first_name.send_keys(line[1])

skipping a few more fields to the button click (and neither the by class name or the xpath work)...

Button = driver.find_element(By.class name("mktoButtonWrap"))
#    Button = driver.find_element_by_xpath('//*[@id="mktoForm_3468"]/div[17]/span')

Button.click()

For the life of me, I can't figure out:

  1. Why the button is not actionable and what I need to do to click it. (Major problem)

  2. Why Python won't run with the following find_element line (minor annoyance)

    Button = driver.find_element(By.xpath('//*[@id="mktoForm_3468"]/div[17]/span')
    

Python is throwing an error that

'AttributeError: type object 'By' has no attribute 'xpath' 

But I'm initializing with:

from selenium.webdriver.common.by import By
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352

2 Answers2

1

You need to consider a couple of things here as follows:

  • Instead of:

    Button = driver.find_element(By.class name("mktoButtonWrap"))
    

    It should have been:

    Button = driver.find_element(By.CLASS_NAME, "mktoButtonWrap")
    

    Similarly,

    Button = driver.find_element(By.XPATH, '//*[@id="mktoForm_3468"]/div[17]/span')
    
  • Further, this error message...

    selenium.common.exceptions.ElementNotInteractableException: Message: element not interactable
    

    indicates that the desired element is not interactable.


Solution

To click on Register you need to induce WebDriverWait for the element_to_be_clickable() and you can use either of the following locator strategies:

  • Using XPATH:

    driver.get("https://discover.workato.com/automate-2022/p/1?utm_source=Automate+2022&utm_medium=employee+referral&utm_campaign=MCoblentz")
    driver.execute_script("arguments[0].click();", WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "//button[@class='mktoButton' and text()='Register']"))))
    
  • Note: You have to add the following imports :

    from selenium.webdriver.support.ui import WebDriverWait
    from selenium.webdriver.common.by import By
    from selenium.webdriver.support import expected_conditions as EC
    
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
  • I'm getting a timeout on the button. I tried both `Button = driver.execute_script("arguments[0].click();", WebDriverWait(driver, 2).until(EC.element_to_be_clickable((By.XPATH, '//*[@id="mktoForm_3468"]/div[17]/span'))))` and your suggestion; both timed out. The button is always clickable; the form requires all fields to be submitted. I am filling out the fields before attempting to submit. Not sure why this is timing out. Any suggestions, @undetectedSelenium? – Matt Coblentz May 03 '22 at 02:03
1

Your syntax is incorrect. It should be:

Button = driver.find_element(By.XPATH, '//*[@id="mktoForm_3468"]/div[17]/span')

If you import By correctly (from selenium.webdriver.common.by import By), your IDE should autocorrect and show correct options: enter image description here

BillyZee
  • 96
  • 1
  • 2
  • In reverse order: thank you @billyzee, for the syntax. Atom is color-coding ... I must have been off by something subtle. It's working now. – Matt Coblentz May 03 '22 at 02:01
  • as in, your suggested syntax corrections are helping me avoid the warning. Still have the problem with the button click. – Matt Coblentz May 03 '22 at 02:08