- selecting great css selectors, not just good ones\n- limited writing on the interwebs\n- less redesign, more stable and robust tests\n
- Be minimally specific - what’s the simplest and most unique way to direct selenium to css elements on our HTML page\n- having id's or classes in your HTML that in some cases will only be used by tests\n- try not to use selectors that are so specific that a harmless redesign will causes tests to fail incorrectly\n\n
- so if testing your html is hard for whatever reason, add classes and id's to elements in your HTML so it’s easier to test\n- this lowers the cost of testing (may increase the cost of development/designing)\n- may be of no value to the javascript, designer or user but your tests become more stable\n\n
- Sign In element on Etsy’s homepage\n- Use firebug to Inspect Element\n- id, class, title, href, CSS attributes\n
selects any element with an id attribute equal to sign-in\n
pseudo class selector\nnot a css expression instead it’s a JS function called locateElementByLinkText()\ngrabs all the A elements out of the DOM then loops through them looking for the one whose innerText property matches the regular expression provided (in this case Sign In)\n
selects any list item element with a class attribute that contains the word sign-in-link\n\n
\n
class button-large-cart will get us the element we want (selenium works by selecting the first element that matches)\n
using pseudo class again\nselects any input element that is a descendant of any element with a class attribute that contains the word button-large-cart\nmultiple elements with the same class don't seem very easy to handle with pure CSS.  In a Ruby Script, wouldn't you just say "css=button-large-cart", and then assign the resulting list of elements to a Ruby array and work with the Ruby array\n\n\n
cases where we want to be vague about elements\n
\n
Good practice to use css id and class selectors, it’s okay to request them, helps with internationalizing your website\n