dtjmsy
dtjmsy

Reputation: 2752

Click on a button in a row in a table

I am having a table:

<table id="tabmailveille">
<tr><td>
<button onclick="return Ajax(162, {'idc': '125').value,'action': 'ajout'});"><img alt="Add" src="/Images/tableaux/add.png" class="buttonimg"></button>
</td>
</tr>
</table>

All I want to do is trying to click the button.

So I tried:

<tr>
    <td>click</td>
    <td>//table[@id='tabmailveille']/tr/td/button[@class='buttonimg']</td>
    <td></td>
</tr>

It doesn't work. The button is not clicked. What's wrong with the code?

Cheers

Upvotes: 2

Views: 713

Answers (1)

user4925383
user4925383

Reputation:

Button element is not assigned a class. Image element is. Therefore xpath is incorrect.

Correct XPath:

//table[@id='tabmailveille']/tr/td/button/img[@class='buttonimg']

Upvotes: 2

Related Questions