You are on page 1of 21

Improve Testing Efficiency With Selenium WebDriver

Surendran Ethiraj
Xpanxion International Pvt. Ltd

Agenda
Selenium An Intro Selenium Tools Suite Selenium RC (Versus) Selenium WebDriver Whats new? - Selenium WebDriver Advanced concepts in WebDriver Demo

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.

Seleniums Tool Suite


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

Selenium RC

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.

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
8

Using Java/JQuery Scripts


Selenium 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!');");

Retrieving JavaScript Errors

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);

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].getAttr ibute("JSError"); $("body").attr("JSError",previous_errors + '\n' + msg ); } </script>

Broken Links

Handling Wait in WebDriver


Fluent Wait (withTimeOut, Polling mechanism) Implicit Wait (withTimeOut) Ajax load Wait (Developed through JQuery for verifying AJAX calls)

HAR (Http Archive Report)


Exports HTTP tracing information for performance analytics

Data from HAR file


How long it takes to fetch the DNS information How long each object takes to be requested How long it takes to connect to the server How long it takes to transfer from the server to the browser of each object Whether the object is blocked or not

Cross Browser Testing with Grid 2.0

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.

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

For Queries write to me at


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

You might also like