21
Improve Testing Efficiency With Selenium WebDriver Surendran Ethiraj Xpanxion International Pvt. Ltd

Indic threads pune12-improve testing efficiency with selenium webdriver

Embed Size (px)

DESCRIPTION

The 7th Annual IndicThreads Pune Conference was held on 14-15 December 2012. http://pune12.indicthreads.com/

Citation preview

Page 1: Indic threads pune12-improve testing efficiency with selenium webdriver

Improve Testing Efficiency With Selenium WebDriverSurendran EthirajXpanxion International Pvt. Ltd

Page 2: Indic threads pune12-improve testing efficiency with selenium webdriver

Agenda

Selenium – An IntroSelenium Tool’s SuiteSelenium RC (Versus) Selenium WebDriverWhat’s new? - Selenium WebDriverAdvanced concepts in WebDriverDemo

Page 3: Indic threads pune12-improve testing efficiency with selenium webdriver

What is Selenium?

• Selenium is a set of different software tools for automating web applications.

• Can be used for most of the browser/platform combinations.

• Supports many languages including Ruby, Python, Java etc.

• Open source and free.

Page 4: Indic threads pune12-improve testing efficiency with selenium webdriver

Selenium’s Tool Suite

• Selenium IDE.• Selenium RC.• Selenium 2.0 (WebDriver).• Selenium Grid.

Page 5: Indic threads pune12-improve testing efficiency with selenium webdriver

Selenium RC

Page 6: Indic threads pune12-improve testing efficiency with selenium webdriver

Selenium WebDriver

Page 7: Indic threads pune12-improve testing efficiency with selenium webdriver

Advantages of WebDriver

One should use WebDriver when requiring improved support for

* Multi-browser testing including improved functionality for browsers not well-supported by Selenium-1.0.* Handling multiple frames, multiple browser windows, popups, and alerts.* Page navigation.* Drag-and-drop.* AJAX-based UI elements.

Page 8: Indic threads pune12-improve testing efficiency with selenium webdriver

8

Advancing in WebDriver

Using Java/JQuery scripts Retrieving Java script errors Identifying broken links Handling ‘Wait’ in WebDriver Reporting Server-client responses Reporting Page load timings Cross browser testing

Page 9: Indic threads pune12-improve testing efficiency with selenium webdriver

Using Java/JQuery ScriptsSelenium WebDriver 2.0 provides us an Interface ‘JavaScriptExecutor’ to execute JS/Jquery scripts independent or within the application

JavascriptExecutor js = (JavascriptExecutor) driver;

js.executeScript("alert('Hello from Selenium!');");

Page 10: Indic threads pune12-improve testing efficiency with selenium webdriver

Retrieving JavaScript Errors

Page 11: Indic threads pune12-improve testing efficiency with selenium webdriver

Identifying JSErrors Cross Browser

For Firefox :We have to add an plugin

“JSErrorCollector.xpi” in Firefox profile which aids to identify the Java script errors on the page and the same could be retrieved using JavaScriptErrorCollector API.

List<JavaScriptError> jsErrors = JavaScriptError.readErrors(driver);

Page 12: Indic threads pune12-improve testing efficiency with selenium webdriver

Other Browsers:For Other Browsers: We need to add the below code in our application

and use JavaScript query to retrieving the details<script type="text/javascript">

window.onerror=function(msg){

var previous_errors = document.getElementsByTagName("body")[0].getAttribute("JSError");

$("body").attr("JSError",previous_errors + '\n' + msg );

}

</script>

Page 13: Indic threads pune12-improve testing efficiency with selenium webdriver

Broken Links

Page 14: Indic threads pune12-improve testing efficiency with selenium webdriver

Handling ‘Wait’ in WebDriver

Fluent Wait (withTimeOut, Polling mechanism)

Implicit Wait (withTimeOut)

Ajax load Wait (Developed through JQuery for verifying AJAX calls)

Page 15: Indic threads pune12-improve testing efficiency with selenium webdriver

HAR (Http Archive Report)

• Exports HTTP tracing information for performance analytics

Page 16: Indic threads pune12-improve testing efficiency with selenium webdriver

Data from HAR file

How long it takes to fetch the DNS information

How long each object takes to be requestedHow long it takes to connect to the serverHow long it takes to transfer from the

server to the browser of each objectWhether the object is blocked or not

Page 17: Indic threads pune12-improve testing efficiency with selenium webdriver

Cross Browser Testing with Grid 2.0

Page 18: Indic threads pune12-improve testing efficiency with selenium webdriver

SikuliWebDriver

SikuliFirefoxDriver extends Selenium's FirefoxDriver by adding Sikuli's image search capability. It is useful for automating interactions with highly visual interfaces such as Google Map.

Page 19: Indic threads pune12-improve testing efficiency with selenium webdriver
Page 20: Indic threads pune12-improve testing efficiency with selenium webdriver

“Testing is an infinite process of comparing the invisible to the ambiguous in order to avoid the unthinkable happening to the anonymous.” - James Bach

Page 21: Indic threads pune12-improve testing efficiency with selenium webdriver

For Queries write to me [email protected]

Linked In: in.linkedin.com/pub/surendran-ethiraj/5/946/a11