2015-11-02 100 views
0

我正在尝试使用selenium webdriver python自动化某些东西。我在这样做的过程中取得了部分成功。我在两者之间崭露头角。无法通过硒python来单击表中的超链接

<td role="gridcell" style="" title="6563378117093014222" aria-describedby="devices_x1AccountId"> 
 
    <a href="accountSummary?accountId=6563378117093014222">6563378117093014222</a> 
 
</td>

我试图单击表描述符中的超级链接,但它显示出一些错误。

这里是我的代码:

deviceID = browser.find_elements(By.XPATH, "//*[@aria-describedby= 'devices_billingId']/a") 
deviceID.click() 

我不知道我做错了。请提出一些解决的find_elements

+0

什么样的错误你得到? – Sighil

+0

@Rajesh你可能会搜索错误的咏叹调描述 - >看我更新的答案 – drkthng

+0

@drkthng它的错字。即使我有另一种场景,我正在使用'devices_x1AccountId'。 – Rajesh

回答

2

使用find_element代替然后在您的XPath您正在搜索“devices_billingId”,但在你的代码中的唱段,describedby是“devices_x1AccountId”

deviceID = browser.find_element_by_xpath("//*[@aria-describedby= 'devices_x1AccountId']/a") 
deviceID.click() 
+0

AttributeError:'list'对象没有'click'属性。我尝试使用find_element以及它不工作:( – Rajesh

+1

@Rajesh,'find_element'应该返回一个'WebElement',而不是'list'。你做的事情是错误的。@drkthng绝对正确 – sircapsalot

+0

我得到错误“无法找到元素“后,将其更改为find_element – Rajesh

相关问题