Nagarjuna Reddy
Nagarjuna Reddy

Reputation: 819

How to click on required button with same class using selenium

In a specific screen, there are three buttons(Advaced Mode, Next, Cancel) in one page with same input class under one div style.Using selenium webdriver, i have automate these.

Using Selenium Webdriver, i have to automate these. if i make use of xpath i can click on required button. But i dont want to depend on xpath, so i'm looking for altenate solution like css related identifications.

Advanced Mode: input class="submit" type="button" value="Advanced Mode" onclick="goAdvance()"

Next: input class="submit" type="button" value="Next" onclick="saveProfile()"

Cancel: input class="submit" type="button" value="Cancel" onclick="goHome(1)

Upvotes: 0

Views: 1777

Answers (2)

Caren
Caren

Reputation: 1418

give this a read: http://sauceio.com/index.php/2010/01/selenium-totw-css-selectors-in-selenium-demystified/

Generally... Advanced Mode: input[value="Advanced Mode"]

Next: input[value="Next"]

Cancel: input[value="Cancel"]

Upvotes: 1

Nathan Merrill
Nathan Merrill

Reputation: 8386

In CSS you can select by any of the attributes. input[value="XXXX"], replacing XXXX, will work. You could also to .submit[value="XXXX"]

Upvotes: 0

Related Questions