Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What attributes do you use for Selenium testing? [closed]

Tags:

selenium

We can search for specific field on website in a few ways: based on css, name, id, structure, even any text found. Which way have you decided to use?

What would be best practice for it?

Edit: I'm asking from developer perspective: How to write code that it will be easier to test with Selenium by one method (that is: being able to search all of them by it's name)

like image 312
Urszula Karzelek Avatar asked Jan 23 '23 16:01

Urszula Karzelek


1 Answers

We generally stay away from xml structure, which turns out to generate way too fragile tests. Our internal organization makes CSS names off-limits, since that is for the design people to manipulate. You don't want your tests to break because someone changes style from heading1 to heading2.

We have opted for a solution that is mainly based on id's. Sometimes we even instrument the HTML with id's just to be able to selenium test.

Additionally we also look for texts (application texts), but internationalization makes this a bit of a pain; we have made our test fixture locale aware.

like image 53
krosenvold Avatar answered Apr 02 '23 01:04

krosenvold