以下代码不会终止。可能是什么原因?
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
driver = webdriver.Firefox()
driver.get("http://www.quora.com/physics")
elem = driver.find_element_by_class_name("cancel")
#ele=elem[0]
print "done"
答案 0 :(得分:1)
尝试使用linkText而不是className。当我尝试时它正在工作。
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
driver = webdriver.Firefox()
driver.get("http://www.quora.com/physics")
elem = driver.find_element_by_link_text("Close & Read Quora")
print "done"