Testing: Selenium: ZimbraSelenium Tips: Difference between revisions
(Created page with '==General Information== This page details some helpful tips regarding usage of the Zimbra Selenium Harness ==Code== ===Selenium=== ====Locators==== Using the most optimal lo…') |
No edit summary |
||
Line 7: | Line 7: | ||
===Selenium=== | ===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 [http://release.seleniumhq.org/selenium-remote-control/0.9.2/doc/dotnet/Selenium.html Selenium documentation], the preferred format of locators is: | Using the most optimal locators is crucial for cross-browser compatibility. IE is notoriously slow for processing xpath locators. As per the [http://release.seleniumhq.org/selenium-remote-control/0.9.2/doc/dotnet/Selenium.html Selenium documentation], the preferred format of locators is: | ||
Line 15: | Line 15: | ||
# by xpath (i.e. locator="//a(@href='@id3']") | # by xpath (i.e. locator="//a(@href='@id3']") | ||
=====xpath to css | =====Translation: xpath to css===== | ||
{| class="wikitable" style="width: 80%; text-align: center; border: 1px solid blue;" | {| class="wikitable" style="width: 80%; text-align: center; border: 1px solid blue;" border="1" | ||
|- | |- | ||
! xpath | ! xpath | ||
Line 26: | Line 26: | ||
| "xpath=//div[@id='foo']" || "css=div[id='foo']" || "foo" || sIsElementPresent("foo") | | "xpath=//div[@id='foo']" || "css=div[id='foo']" || "foo" || sIsElementPresent("foo") | ||
|- | |- | ||
| "xpath=// | | "xpath=//tr[contains(@attr,'partial']" || "css=tr[attr*='foo']" || "css=tr[attr*='foo']" || sIsElementPresent("css=tr[attr*='foo']") | ||
|} | |} | ||
Revision as of 21: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 Identifier (i.e. locator="DWT233")
- by CSS (i.e. locator="css=a[href='#id3']")
- by xpath (i.e. locator="//a(@href='@id3']")
Translation: xpath to css
xpath | css | preferred | usage |
---|---|---|---|
"xpath=//div[@id='foo']" | "css=div[id='foo']" | "foo" | sIsElementPresent("foo") |
"xpath=//tr[contains(@attr,'partial']" | "css=tr[attr*='foo']" | "css=tr[attr*='foo']" | sIsElementPresent("css=tr[attr*='foo']") |
See http://saucelabs.com/blog/index.php/2010/01/selenium-totw-css-selectors-in-selenium-demystified/