0
Reply

Click on first button if other buttons with same name are present?

The Unknown

The Unknown

Apr 8 2010 2:08 AM
1.9k
I'm using WebBrowser controls in C# to go to a site and if finds text that matches a string it clicks a  Accept button. sometimes however they are other buttons with the same name that are present and this would cause the program to click the wrong button.
In a Dom viewer I found out that all Accept buttons that appear on the page have the same "tagName" and the same "textContent" so no luck there. Also noticed that each button belongs to the same button class as well.
Is there any other way to find the first button and click on it after a condition has been met? 2nd button?

*Update:
Managed to get the Xpath to the 1st and 2nd button using firebug, how can I make my program click on one of these buttons using the Xpath?
the Xpath looks like this:
/html/body/table[2]/tbody/tr[2]/td/table/tbody/tr/td[3]/table/tbody/tr/td/table[2]/tbody/tr[3]/td/table/tbody/tr[3]/td/button