2
我有這行代碼:硒找到XPath的元素,然後單擊
browser=webdriver.Chrome()
...
games1=[]
for x in browser.find_elements_by_xpath("//li[starts-with(@class,'icon_flag')]"):
if x.text!="":
games1.append(x.get_attribute('class'))
然後我試圖讓硒點擊我發現的元素:
for x in games1:
browser.find_element_by_xpath("//li[@class=x]").click()
怎麼可能得到錯誤消息:
消息:沒有這樣的元件:無法找到元素:
這真的很奇怪,因爲我發現網站的元素!
添加一些console.log語句以縮小原因... – JGFMK