Python 2.7 Python Selenium无法单击<;a href="#&引用&燃气轮机;使用javascript
我有以下HTML:Python 2.7 Python Selenium无法单击<;a href="#&引用&燃气轮机;使用javascript,python-2.7,selenium-chromedriver,Python 2.7,Selenium Chromedriver,我有以下HTML: <ul id="TopMenuTabs"> <li>...</li> <li class="active"> <a href="#" onclick="formaction='topbasic';document.frmEPO.button.value='topbasic'; if( ValidateForm() ) document.frmEPO.submit(); return fals
<ul id="TopMenuTabs">
<li>...</li>
<li class="active">
<a href="#" onclick="formaction='topbasic';document.frmEPO.button.value='topbasic'; if( ValidateForm() ) document.frmEPO.submit(); return false;">Reports</a>
</li>
</ul>
当我运行它时,url将“#”添加到末尾,这样它就可以识别click()命令,但实际上似乎没有单击它或执行javascript。我已经尝试使用time.sleep长达30秒,以确保它不仅仅是一个页面加载问题,而且没有成功。它总是移动到下一行并出错,因为页面没有更改。真的不知道下一步该怎么办 我还使用了just.click(),同样的结果,显然当你为一个元素使用索引时,它不是0索引的,所以它应该是…li[2]。。。我都准备好了!
driver.find_element_by_xpath("//ul[@id='TopMenuTabs']/li[1]/a").click().perform()