大家好,我是最近幾個禮拜才開始練習python的新手
最近在看Python自動化的樂趣這本書,想要弄一個橘子beanfun自動登入器來玩玩看
可是一直遇到無法定位帳密輸入元素的問題,程式碼如下:
import time
from selenium import webdriver
from selenium.webdriver.support.ui import Select
driver = webdriver.Chrome()
driver.get(url)
time.sleep(0.2)
link = driver.find_element_by_link_text("登入")
link.click()
time.sleep(0.2)
select = Select(driver.find_element_by_name('ddlAuthType'))
select.select_by_value('1')
account = driver.find_element_by_id("t_AccountID")
account.send_keys('XXX')
time.sleep(0.2)
password = driver.find_element_by_id("t_Password")
password.send_keys('XXX')
time.sleep(0.2)
password.submit()
selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"id","selector":"t_AccountID"}
一開始以為是下拉式選單沒選的問題,可是弄了之後還是沒辦法
之前在玩youtube自動搜尋的時候也會遇到無法定位元素的問題,還麻煩各位大大提點了,感謝~~