user3008973
user3008973

Reputation: 1

Locating elements in selenium IDE

I have tried to locate button in my web app using xpath but it changes automatically each time I open selenium IDE. Is there any other way to locate it except using xpath or position? can I locate it using class name? If yes then how can I do it?

Upvotes: 0

Views: 647

Answers (4)

ism
ism

Reputation: 298

Use a CSS selector. This site really helped me: http://saucelabs.com/resources/selenium/css-selectors

if it has an id on it you can just say "id=yourid"

for css it could be something like this: "css=button[class*='yourclass']" <-- that says it's a button, and that in class it contains yourclass.

Upvotes: 0

Prashant Baviskar
Prashant Baviskar

Reputation: 1

Answer - If by default recorded xpath are not working for your application, then you can define your own xpath for those components which should remain same throughout execution.

Please refer below URL which shows ways to develop userdefined xpath :-

http://docs.seleniumhq.org/docs/appendix_locating_techniques.jsp

Upvotes: 0

MxLDevs
MxLDevs

Reputation: 19516

Since it is your webapp, consider adding an id or a name to uniquely identify the element. It also makes the xpaths easier to write as you don't need to consider the possibility where you might be grabbing too many elements.

Upvotes: 0

ievche
ievche

Reputation: 1805

You can use xpath to find element by class name.

//*[@class='someClass']

where, someClass is the class name of your element.

Upvotes: 1

Related Questions