如下丑陋的 code,用这样的语法找不到元素,不知为何 # button = driver.find_element_by_css_selector("li.'fa fa-ok-sign'") # button = driver.find_elements_by_class_name("fa fa-ok-sign")
另外如何判断是否已经领过了:driver.find_element_by_css_selector 返回的是个 exception,没有 if else 方便. 不知怎么判断分支比较好.
driver.get('https://www.v2ex.com/mission/daily')
print "here stop -----"
try:
button = driver.find_element_by_xpath("//input[@type='button' and @value='领取 X 铜币']")
except NoSuchElementException as msg:
print u"no find the elecment: %s, may be has got the money? "%msg;
try:
button = driver.find_elements_by_xpath("//li[@class='fa fa-ok-sign']")
## 如下丑陋的 code,用这样的语法找不到元素,不知为何
# button = driver.find_element_by_css_selector("li.'fa fa-ok-sign'")
# button = driver.find_elements_by_class_name("fa fa-ok-sign")