我有這個代碼的問題輸入字符串:無法點擊使用python
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
#Getting local session of Chrome
driver=webdriver.Chrome()
#put here the adress of your page
driver.get("https://www.google.co.in")
#put here the content you have put in Notepad, ie the XPath
elem=driver.find_elements_by_name('q')############### this is one of name
elem.send_keys("google search through python")
driver.close()
輸出正顯示出ELEM列表爲空 爲什麼會出現空列表?
Traceback (most recent call last):
File "google.py", line 14, in <module>
elem.send_keys("google search through python")
AttributeError: 'list' object has no attribute 'send_keys'
任何人都可以幫助我跟蹤問題嗎?
錯誤'elem'是** **列表名稱爲「Q」的所有元素。選擇你想要應用'send_keys'的人。例如,將您的代碼更改爲'elem [0] .send_keys(「bla」)'。 – Maroun