简体   繁体   中英

Unable to access the element using Selenium , Python and ChromeDriver

Unable to Access the password by name tried this from a stackoverflow answer but still not working

 <input type="password" class="required valid" style="font-size: 14px; margin-top: 1em; padding: 0.3em;important: width; 100%:important; border-radius: 3px;" placeholder="password" name="password">

Code trials:

WebDriverWait(driver, 10).until(
    EC.presence_of_element_located(
        (By.NAME, passwordId))
).click()

driver.find_element_by_name(passwordId).send_keys(password)

Instead of presence_of_element_located() you need to induce WebDriverWait for the element_to_be_clickable() and you can use either of the following Locator Strategies :

  • Using NAME :

     WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.NAME, "password"))).click()
  • Using CSS_SELECTOR :

     WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.CSS_SELECTOR, "input[name='password'][placeholder='password']"))).click()
  • Using XPATH :

     WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "//input[@name='password' and @placeholder='password']"))).click()
  • 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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM