這是我的源代碼:硒如何點擊
<a id="form_week:btn_before" title="Précedent" onclick="var cf = function(){disableLink('btn_before');};var oamSF = function(){return oamSubmitForm('form_week','form_week:btn_before');};return (cf()==false)? false : oamSF();" href="#">
如何點擊該鏈接?
編輯:
我測試您的三個答案,但
mydriver.find_element_by_xpath('//a[@title="Précedent"]').click()
File "/Library/Python/2.7/site-packages/selenium/webdriver/remote/webdriver.py", line 230, in find_element_by_xpath
return self.find_element(by=By.XPATH, value=xpath)
File "/Library/Python/2.7/site-packages/selenium/webdriver/remote/webdriver.py", line 662, in find_element
{'using': by, 'value': value})['value']
File "/Library/Python/2.7/site-packages/selenium/webdriver/remote/webdriver.py", line 173, in execute
self.error_handler.check_response(response)
File "/Library/Python/2.7/site-packages/selenium/webdriver/remote/errorhandler.py", line 166, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.NoSuchElementException
解決:
這是我的錯,我沒有看到,元素a,是在一個iframe中。
mydriver.switch_to_frame(mydriver.find_element_by_xpath("//iframe"));
mydriver.find_element_by_id('form_week:btn_before').click()