A
A
adrenalinruslan2019-06-12 11:29:52
Python
adrenalinruslan, 2019-06-12 11:29:52

Selenium python expect element on page?

Why am I getting an error? How to fix it ? I want the script to click on the "Next" button after entering "Email" - this basically works, after clicking it should wait until the element appears and after that the script filled in the "Password" field, but I get an error. ..

import os
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC

browser = webdriver.Chrome(os.path.dirname(os.path.abspath(__file__)) + '\\chromedriver.exe')
browser.get('test')

browser.find_element_by_css_selector("input[type='email'][aria-label='Телефон или адрес эл. почты'][name='identifier']").send_keys('test')
browser.find_element_by_css_selector("div[role='button'][id='identifierNext']").click()

WebDriverWait(browser, 10).until(EC.presence_of_element_located((By.CSS_SELECTOR, "input[type='password'][aria-label='Введите пароль'][name='password']")))

browser.find_element_by_css_selector("input[type='password'][aria-label='Введите пароль'][name='password']").send_keys('test')
browser.find_element_by_css_selector("div[role='button'][id='passwordNext']").click()

browser.close()
quit()

The error itself:
Traceback (most recent call last):
  File "app.py", line 17, in <module>
    browser.find_element_by_css_selector("input[type='password'][aria-label='Вве
дите пароль'][name='password']").send_keys('test')
  File "C:\Users\RIMBL\AppData\Local\Programs\Python\Python37-32\lib\site-packag
es\selenium\webdriver\remote\webelement.py", line 479, in send_keys
    'value': keys_to_typing(value)})
  File "C:\Users\RIMBL\AppData\Local\Programs\Python\Python37-32\lib\site-packag
es\selenium\webdriver\remote\webelement.py", line 633, in _execute
    return self._parent.execute(command, params)
  File "C:\Users\RIMBL\AppData\Local\Programs\Python\Python37-32\lib\site-packag
es\selenium\webdriver\remote\webdriver.py", line 321, in execute
    self.error_handler.check_response(response)
  File "C:\Users\RIMBL\AppData\Local\Programs\Python\Python37-32\lib\site-packag
es\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=75.0.3770.80)
  (Driver info: chromedriver=74.0.3729.6 (255758eccf3d244491b8a1317aa76e1ce10d57
e9-refs/branch-heads/[email protected]{#29}),platform=Windows NT 6.1.7601 SP1 x86_64)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
1
1001001, 2019-06-12
@adrenalinruslan

Are you sure the field doesn't always exist? Perhaps visibility_of_element_located should be used.
Or you're filling in the wrong element...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question