0

I'm trying to send_keys()` to a specific input box on a website and I get an error that says that the element is not interactable, as seen below (including code):

def createEmails():
    url = "myurl"
    driver = webdriver.Chrome()
    driver.get(url)

    print(f"{Fore.YELLOW}[!] Waiting for website to load fully.")
    time.sleep(5)

    username, password = generateData()

    usernameField = driver.find_element(By.ID, "email")
    usernameField.send_keys(username)
Traceback (most recent call last):
  File "C:\Users\lukap\Desktop\ASDF\creatorasdf.py", line 97, in <module>
    main()
  File "C:\Users\lukap\Desktop\ASDF\creatorasdf.py", line 41, in main
    chosenOption(optionInput)
  File "C:\Users\lukap\Desktop\ASDF\creatorasdf.py", line 47, in chosenOption
    createEmails()
  File "C:\Users\lukap\Desktop\ASDF\creatorasdf.py", line 70, in createEmails
    usernameField.send_keys(username)
  File "C:\Users\lukap\AppData\Local\Programs\Python\Python310\lib\site-packages\selenium\webdriver\remote\webelement.py", line 477, in send_keys
    self._execute(Command.SEND_KEYS_TO_ELEMENT,
  File "C:\Users\lukap\AppData\Local\Programs\Python\Python310\lib\site-packages\selenium\webdriver\remote\webelement.py", line 633, in _execute
    return self._parent.execute(command, params)
  File "C:\Users\lukap\AppData\Local\Programs\Python\Python310\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 321, in execute
    self.error_handler.check_response(response)
  File "C:\Users\lukap\AppData\Local\Programs\Python\Python310\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 242, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.ElementNotInteractableException: Message: element not interactable
  (Session info: chrome=114.0.5735.134)

I am not sure what do to, had already found some answer and nothing helped fix my issue.

I'm trying to make an account on a service called Proton.me

komko
  • 112
  • 1
  • 1
  • 8
  • I tried using implicitily_wait and some guy mentioned I should do it w/ ActionChains but it didn't work – komko Jun 23 '23 at 19:02
  • I don't find _usernameField_ field on https://proton.me/ landing page neither any code attempts. – undetected Selenium Jun 23 '23 at 19:05
  • Well the register page is on https://account.proton.me/signup?plan=free&billing=12&ref=prctbl&minimumCycle=12&currency=EUR&product=mail&language=en and also the usernameField is just the variable in my code for an inputbox with id email. – komko Jun 23 '23 at 19:12

2 Answers2

0

you have an iframe tag in the html of the website you mentioned above that you have to switch to it first then you can find the email element , you can find the iframe using its xpath enter image description here

frame_element = driver.find_element(By.XPATH, "/html/body/div[1]/div[4]/div[1]/main/div[1]/div[2]/form/iframe")
driver.switch_to.frame(frame_element)

usernameField = driver.find_element(By.ID, "email")
usernameField.send_keys('username')
0

The Username field is within an <iframe> so you have to:

  • Induce WebDriverWait for the desired frame to be available and switch to it.

  • Induce WebDriverWait for the desired element to be clickable.

  • You can use either of the following locator strategies:

    • Using CSS_SELECTOR:

      driver.get("https://account.proton.me/signup?plan=free&billing=12&ref=prctbl&minimumCycle=12&currency=EUR&product=mail&language=en")
      WebDriverWait(driver, 20).until(EC.frame_to_be_available_and_switch_to_it((By.CSS_SELECTOR,"iframe[title='Username']")))
      WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.CSS_SELECTOR, "input#email"))).send_keys("komko")
      
    • Using XPATH:

      driver.get("https://account.proton.me/signup?plan=free&billing=12&ref=prctbl&minimumCycle=12&currency=EUR&product=mail&language=en")
      WebDriverWait(driver, 20).until(EC.frame_to_be_available_and_switch_to_it((By.XPATH,"//iframe[@title='Username']")))
      WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "//input[@id='email']"))).send_keys("komko")
      
  • 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
    
  • Browser Snapshot:

proton


Reference

You can find a couple of relevant discussions in:

undetected Selenium
  • 183,867
  • 41
  • 278
  • 352