Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/python-2.7/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 2.7 使用Python和Selenium webdriver在丑陋的表中查找并单击链接_Python 2.7_Selenium_Xpath_Web Scraping - Fatal编程技术网

Python 2.7 使用Python和Selenium webdriver在丑陋的表中查找并单击链接

Python 2.7 使用Python和Selenium webdriver在丑陋的表中查找并单击链接,python-2.7,selenium,xpath,web-scraping,Python 2.7,Selenium,Xpath,Web Scraping,我试图让Selenium Webdriver单击表中的链接数,但无法使其正常工作。我可以这样打印链接: links = driver.find_elements_by_xpath("//table[2]/tbody/tr/td/p/strong/a") for i in range(0,len(links)): print links[i].text 但是当我尝试执行链接[I]时,单击()而不是打印,python会抛出一个错误 该网站使用JSP,链接的hrefs看起来像“javascr

我试图让Selenium Webdriver单击表中的链接数,但无法使其正常工作。我可以这样打印链接:

links = driver.find_elements_by_xpath("//table[2]/tbody/tr/td/p/strong/a")
for i in range(0,len(links)):
    print links[i].text
但是当我尝试执行
链接[I]时,单击()
而不是打印,python会抛出一个错误

该网站使用
JSP
,链接的
hrefs
看起来像“javascript:loadTestResult(169)” 这是一个子/子页面,无法通过直接URL访问,并且包含链接的表非常凌乱和庞大,因此我没有在此处粘贴整个源代码,而是将页面保存在此URL上


(我正在搜索左列中的12个蓝色链接)

有什么想法吗

谢谢 马丁

对不起,我很高兴。 我自己问题的简单解决方案:

linkList = driver.find_elements_by_css_selector("a[href*='loadTestResult']")
for i in range(0,len(linkList)):
        links = driver.find_elements_by_css_selector("a[href*='loadTestResult']")
        links[i].click()