2 回答

TA貢獻(xiàn)1804條經(jīng)驗(yàn) 獲得超3個(gè)贊
您應(yīng)該嘗試在輸入中設(shè)置值,但您當(dāng)前的代碼正在獲取div
元素,而輸入框正在攔截對(duì) div 元素的點(diǎn)擊。相反,請(qǐng)嘗試使用下面的代碼行。
text_area= driver.find_element_by_xpath("//input[@name='identifier']")

TA貢獻(xiàn)1856條經(jīng)驗(yàn) 獲得超5個(gè)贊
您可以使用waits,即:
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
from selenium.webdriver.common.keys import Keys
driver = webdriver.Chrome(executable_path="C:\Users\user\Downloads\chromedriver_win32\chromedriver.exe")
driver.maximize_window()
driver.get("https://accounts.google.com/signin/v2/identifier?passive=1209600&continue=https%3A%2F%2Fdocs.google.com%2F&followup=https%3A%2F%2Fdocs.google.com%2F&emr=1&flowName=GlifWebSignIn&flowEntry=ServiceLogin")
wait = WebDriverWait(driver, 10)
# usr
el = wait.until(EC.visibility_of_element_located((By.ID, "identifierId")))
el.send_keys("username@gmail.com")
el.send_keys(Keys.ENTER)
# pwd
el = wait.until(EC.visibility_of_element_located((By.XPATH, "//input[@type='password']")))
el.send_keys("XXXXX")
el.send_keys(Keys.ENTER)
# you're logged
- 2 回答
- 0 關(guān)注
- 360 瀏覽
添加回答
舉報(bào)