DevEX - reference for building teams, processes, and platforms
Automated Web Testing Using Selenium
1.
2. Automated Web Testing using Selenium Perficient China Waylon Zhang Yahoo!m: waylon_zhang2008 [email_address]
3.
4.
5.
6.
7. Selenium components *Selenese is the set of Selenium Commands that run you tests. Don’t support If or For (While) statements C#, Java, Perl, PHP, Python, Ruby Selenese *Selenese Programming Languages Yes No No Support I&O Yes No No Need Jre Yes Yes No Different Domain Yes Yes Yes Support Https/SSL No No Yes AUT Server side installed Firefox, IE,Safari Firefox Firefox, IE,Safari Browsers Selenium Remote Control Selenium IDE Selenium Core
Add js to user-extensions.js: Selenium.prototype.getTableRows = function(locator) { /** * Gets the number of rows in a table. * * @param locator element locator for table * @return number of rows in the table, 0 if none */ var table = this.browserbot.findElement(locator); return table.rows.length.toString(); }; Selenium.java: String getTableRows(String locator); DefaultSelenium.java: public String getTableRows(String locator){ return commandProcessor.getString("getTableRows", new String[] {locator,}); } Test Method: public void testTables() throws InterruptedException{ selenium.open("http://www.w3schools.com/tags/tag_table.asp"); Thread. sleep (10000); String rows= selenium.getTableRows("//table[@id='table3']"); System. out .println("rows count= "+rows); }
Add js to user-extensions.js: Selenium.prototype.getTableRows = function(locator) { /** * Gets the number of rows in a table. * * @param locator element locator for table * @return number of rows in the table, 0 if none */ var table = this.browserbot.findElement(locator); return table.rows.length.toString(); }; Selenium.java: String getTableRows(String locator); DefaultSelenium.java: public String getTableRows(String locator){ return commandProcessor.getString("getTableRows", new String[] {locator,}); } Test Method: public void testTables() throws InterruptedException{ selenium.open("http://www.w3schools.com/tags/tag_table.asp"); Thread. sleep (10000); String rows= selenium.getTableRows("//table[@id='table3']"); System. out .println("rows count= "+rows); }
XPath builder can build the XPath from the composite locator, i.e., a set of attributes. Starting with version 0.6.0, Tellurium supports jQuery selectors to address the problem of poor performance of XPath in Internet Explorer. jQuery selector builders are used to automatically generate jQuery selectors instead of XPath with the following advantages: Faster performance in IE. Leverage the power of jQuery to retrieve bulk data from the web by testing with one method call. New features provided by jQuery attribute selectors.