I’m trying to automate testing of the code… well, written without testing in mind (no IDs on many elements, and a lot of elements with the same class names). I would appreciate any help (questions are below the code):
<div id='author-taxonomies' class='menu-opened menu-hover-opened-inactive' onmouseover='styleMenuElement(this)' onmouseout='styleMenuElement(this)' onclick='toggleSFGroup(this)'>Author</div> <div id='author-taxonomies-div' class='opened'> <div id='top-level-menu' class='opened'> <div id='top-level-menu-item-1' class='as-master'> <div class='filter-label'> Name</div> </div> <div id='top-level-menu-item-1' class='as-slave' style='top: 525px; left: 34px; z-index: 100; display: none;'> </div> <div id='top-level-menu-item-2' class='as-master'> <div class='filter-label'>Title</div> </div> <div id='top-level-menu-item-2' class='as-slave'> <div id='top-level-menu-item-2' class='as-slave-title as-slave-title-subgroup' >Title</div> <div id='top-level-menu-item-2' class='as-slave-body'> </div> <div class='as-slave-buffer'> </div> </div> <div id='top-level-menu-item-3' class='as-master'> <div class='filter-label'>Location</div> </div> <div id='top-level-menu-item-3' class='as-slave'> </div> </div> </div>
The question is: how to refer particular labels of this menu and the properties with xPath expressions? For example, if I want to:
- verify the ‘Location’ label is there
- check if ‘Title’ with class ‘as-slave’ is not visible at the moment
It would be something similar to:
Update: also be sure to install the following firefox addin, it is Really useful when trying different xpath expressions on a site https://addons.mozilla.org/en-US/firefox/addon/1095