user2993178 February 2016

How to write xpath for a button with class attribute?

I have just started working on Selenium-Ruby . My html looks something like this-

<button class="check column btn btn-invisible">
   <i class="icon-column-p"></i>
    "Check Column"
</button>

I want to click on the button, what would be the best xpath to access it?

Thanks!

Answers


sunder kandasamy February 2016

You can use:

//button[@class='check column btn btn-invisible']

Or

//button[contains(@class, 'btn')]


Jake Cobb February 2016

You can test against the text of the button with:

//button[contains(., '"Check Column"')]

Post Status

Asked in February 2016
Viewed 3,260 times
Voted 11
Answered 2 times

Search




Leave an answer