单击td/td部分seleniumpython下的链接

2024-04-25 22:46:21 发布

您现在位置:Python中文网/ 问答频道 /正文

我从一个网页上读到一个表格,其中一列有一个链接。桌子是这样的:

</div>
<div class="separator"></div>
<h1>User Management:</h1>
<table>
   <tbody>
      <tr>
         ...
      </tr>
      <tr>
         <td>Johnny@gmail.com</td>
         <td>Johnny</td>
         <td><a class="pointer" onclick="deleteUs('http://localhost/..');">button1</a>
            |<a class="pointer" onclick="resetPas('http://localhost/..');">button2</a>
            |<a href="http://localhost/something/something">button3</a>
         </td>
      </tr>
      <tr>
      </tr>`

我想单击按钮3(在这个表的每一行中都可以找到),它将页面重定向到所提到的href(http://localhost/something/something) 我该怎么做?在


Tags: divlocalhosthttp网页链接h1trsomething
3条回答

下面是一个例子,点击单元格“Johnny”所在行的链接:

driver.find_element_by_xpath("//tr[td='Johnny']//a[@href]").click()

请尝试使用find_element_by_partial_link_text()方法。在

    element = driver.find_element_by_partial_link_text('Jhonny')

希望有帮助。在

谢谢。在

select = Select(driver.find_element_by_xpath("//table//td//a[@class!='pointer']"))
select.click()

或者

^{pr2}$

相关问题 更多 >