0

Through Selenium, I try to enter the username on one popular site, but, for some reason I do not understand, this does not work. Everything opens, a click occurs on the desired input field, but immediately after that an error appears when trying to enter text. Here is my code:

webdriverDir = "./chromedriver.exe"  
home_url = 'https://appleid.apple.com/account/'

browser = webdriver.Chrome(executable_path=webdriverDir)
browser.get(home_url)
elem = browser.find_element_by_id("firstNameInput")
elem.click()
elem.send_keys('namename')
time.sleep(5)

I also tried to change the solution to this:

browser.find_element_by_id("firstNameInput").send_keys("namename")

But it also does not work. I can’t understand what’s the matter. Also tried through xpath, class_name and css_selector. The result was either the same or the element was simply not detected. Although everything was copied from element code from console.

Error Code:

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

Where could there be a mistake? Or can it be the site itself?

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

2 Answers2

0

The element with firstNameInput id is not an input and it's a custom tag and your send-keys commands can not access that element.

what you have to do is, access the input present in the parent element.

driver.find_element_by_css_selector("#firstNameInput input").send_keys('hello')

enter image description here

supputuri
  • 13,644
  • 2
  • 21
  • 39
0

To send a character sequence to the First name field you have to induce WebDriverWait for the element_to_be_clickable() and you can use either of the following Locator Strategies:

  • Using CSS_SELECTOR:

    driver.get("https://appleid.apple.com/account/")
    WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.CSS_SELECTOR, "first-name-input#firstNameInput input"))).send_keys("haruhi")
    
  • Using XPATH:

    driver.get("https://appleid.apple.com/account/")
    WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "//span[@class='form-label' and normalize-space()='First name']//preceding::input[1]"))).send_keys("haruhi")
    
  • 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:

create_your_apple_id

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