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

IndicThreads-Pune12-Improve Testing Efficiency With Selenium WebDriver

Embed Size (px)

Citation preview

Page 1: IndicThreads-Pune12-Improve Testing Efficiency With Selenium WebDriver

Improve Testing Efficiency With Selenium WebDriverSurendran EthirajXpanxion International Pvt. Ltd

Page 2: IndicThreads-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: IndicThreads-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: IndicThreads-Pune12-Improve Testing Efficiency With Selenium WebDriver

Selenium’s Tool Suite

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

Page 5: IndicThreads-Pune12-Improve Testing Efficiency With Selenium WebDriver

Selenium RC

Page 6: IndicThreads-Pune12-Improve Testing Efficiency With Selenium WebDriver

Selenium WebDriver

Page 7: IndicThreads-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: IndicThreads-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: IndicThreads-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: IndicThreads-Pune12-Improve Testing Efficiency With Selenium WebDriver

Retrieving JavaScript Errors

Page 11: IndicThreads-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: IndicThreads-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: IndicThreads-Pune12-Improve Testing Efficiency With Selenium WebDriver

Broken Links

Page 14: IndicThreads-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: IndicThreads-Pune12-Improve Testing Efficiency With Selenium WebDriver

HAR (Http Archive Report)

• Exports HTTP tracing information for performance analytics

Page 16: IndicThreads-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: IndicThreads-Pune12-Improve Testing Efficiency With Selenium WebDriver

Cross Browser Testing with Grid 2.0

Page 18: IndicThreads-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: IndicThreads-Pune12-Improve Testing Efficiency With Selenium WebDriver
Page 20: IndicThreads-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: IndicThreads-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