How to locate the username and password field within Instagram login page using Chromedriver and Selenium Python

后端 未结 4 1694
梦毁少年i
梦毁少年i 2021-01-26 21:50

Here\'s inspected source code

input aria-label=\"Phone number, username, or email\" aria-required=\"true\" autocapitalize=\"off\" autocorrect=\"off\" maxlength=\         


        
4条回答
  •  星月不相逢
    2021-01-26 22:15

    Try the below code:

    driver = webdriver.Chrome()
    driver.get('https://www.instagram.com/')
    txt_user = WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.NAME, 'username')))
    txt_user.send_keys('yourUserName')
    txt_pwd = WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.NAME, 'password')))
    txt_pwd.send_keys('yourPassword')
    btn_submit = WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.CSS_SELECTOR, 'button[type="submit"]')))
    btn_submit.click()
    

    Following import:

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

提交回复
热议问题