Reputation: 21
I'm reading a table from a web page and one of the columns has a link in it. The table is something like this:
</div>
<div class="separator"></div>
<h1>User Management:</h1>
<table>
<tbody>
<tr>
...
</tr>
<tr>
<td>[email protected]</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>`
I want to click on button3(which is found in each row in this table) which gets the page redirects to the mentioned href(http://localhost/something/something) How can I do it?
Upvotes: 0
Views: 5200
Reputation: 1057
Please try with find_element_by_partial_link_text() method.
element = driver.find_element_by_partial_link_text('Jhonny')
Hope it helps.
Thank you .
Upvotes: 1
Reputation: 42518
Here is an example to click on the link of the row having the cell "Johnny" :
driver.find_element_by_xpath("//tr[td='Johnny']//a[@href]").click()
Upvotes: 0
Reputation: 5194
select = Select(driver.find_element_by_xpath("//table//td//a[@class!='pointer']"))
select.click()
or
select = Select(driver.find_element_by_xpath("//table//td//a[3]"))
select.click()
Upvotes: 0