I am on this page: Google Drive Login
Wanting to select this input field:
When I use the xpath of the input field:
//*[@id="identifierId"]
or
/html/body/div[1]/div[1]/div[2]/div/div[2]/div/div/div[2]/div/div[1]/div/form/span/section/div/div/div[1]/div/div[1]/div/div[1]/input
I get nada.
Normally this happens when an element is nested within an iframe but not in this case. Or at least I couldn't find the iframe in question. Please help me understand why.
The Email or Phone field while accessing Google Drive login page is no different from the Email or Phone field during GMail login.
To send a character sequence to the element you can use either of the following Locator Strategies:
Using id
:
driver.find_element_by_id("identifierId").send_keys("AturSams")
Using css_selector
:
driver.find_element_by_css_selector("input#identifierId").send_keys("AturSams")
Using xpath
:
driver.find_element_by_xpath("//input[@id='identifierId']").send_keys("AturSams")
Ideally, to send a character sequence to the element you need to induce WebDriverWait for the element_to_be_clickable()
and you can use either of the following Locator Strategies:
Using ID
:
WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.ID, "identifierId"))).send_keys("AturSams")
Using CSS_SELECTOR
:
WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.CSS_SELECTOR, "input#identifierId"))).send_keys("AturSams")
Using XPATH
:
WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "//input[@id='identifierId']"))).send_keys("AturSams")
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
You can find a couple of relevant detailed discussions in: