Testing: Selenium: ZimbraSelenium Tips: Difference between revisions
No edit summary |
(→Links) |
||
Line 48: | Line 48: | ||
See http://saucelabs.com/blog/index.php/2010/03/selenium-tips-finding-elements-by-their-inner-text-using-contains-a-css-pseudo-class/ | See http://saucelabs.com/blog/index.php/2010/03/selenium-tips-finding-elements-by-their-inner-text-using-contains-a-css-pseudo-class/ | ||
See http://www.ivaturi.org/home/hackingseleniumtoimproveitsperformanceonie | |||
Revision as of 23:48, 4 May 2011
General Information
This page details some helpful tips regarding usage of the Zimbra Selenium Harness
Code
Selenium
Preferred Locator Formats
Using the most optimal locators is crucial for cross-browser compatibility. IE is notoriously slow for processing xpath locators. As per the Selenium documentation, the preferred format of locators is:
- by CSS (i.e. locator="css=a[href='#id3']")
- by xpath (i.e. locator="//a(@href='@id3']")
- by Identifier (i.e. locator="DWT233")
Translation: xpath to css
For those familiar with xpath but not css, here are some tips for translation.
xpath | css | preferred | description |
---|---|---|---|
"xpath=//div[@id='foo']" | "css=div[id='foo']" | "foo" | element with id equals "foo" |
"xpath=//tr[contains(@attr,'partial']" | "css=tr[attr*='foo']" | "css=tr[attr*='foo']" | attr contains foo |
- | "css=tr[attr^='foo']" | "css=tr[attr^='foo']" | attribute starts with foo |
- | "css=tr[attr$='foo']" | "css=tr[attr$='foo']" | attribute ends with foo |
xpath=(//div[@id='foo'])@class | "css=div[id='foo']@class" | sGetAttribute("css=div[id='foo']@class") | CSS format for sGetAttribute() |
xpath=//div//table | "css=div table" | "css=div table" | descendant |
xpath=//div/table | "css=div>table" | "css=div>table" | child |
Links
See http://saucelabs.com/blog/index.php/2010/01/selenium-totw-css-selectors-in-selenium-demystified/
See http://www.ivaturi.org/home/hackingseleniumtoimproveitsperformanceonie