I have a web page with multiple tables , all the tables have TR with a similar TD
here is that button in an ObservationStation table
<input type="button" class="gwf-round-button" value="^" onclick="InsertRowBefore('ObservationStations', this, 'TextBox')" title="Add row before">
And here it is in a MeteorlogicalVariables table
<input type="button" class="gwf-round-button" value="^" onclick="InsertRowBefore('MeteorologicalVariables', this, 'TextBox')" title="Add row before">
What I want to do is select the first occurrence of the button in the MeteorlogicalVariables table and click it. The only identifier that differentiate the buttons in the each table is in the onclick , how would I access the very first button in the MeteorlogicalVariables table ?
here is what I have now:
edit_button = driver.find_element("xpath", '//button[text()="^" and @class="gwf-round-button"][1]')
edit_button.click()
here is what the MeteorologicalVariables table looks like (the highlighted button is what I want to click):
any help in getting this figured out is appreciated
Your XPath
is wrong, it looks there’s no text = ^
Try this XPath
:
//button[@title="Add row before"]
via:
edit_button = driver.find_element("xpath", '//button[@title="Add row before"]')