2. Agenda
Selenium – An Intro
Selenium Tool’s Suite
Selenium RC (Versus) Selenium WebDriver
What’s new? - Selenium WebDriver
Advanced concepts in WebDriver
Demo
3. 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.
7. 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.
9. 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!');");
11. 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);
12. 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>
14. Handling ‘Wait’ in WebDriver
Fluent Wait
(withTimeOut,
Polling mechanism)
Implicit Wait
(withTimeOut)
Ajax load Wait
(Developed through
JQuery for verifying
AJAX calls)
15. HAR (Http Archive Report)
• Exports HTTP tracing information for
performance analytics
16. 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
20. “Testing is an infinite process of comparing the invisible to the
ambiguous in order to avoid the unthinkable happening to the
anonymous.” - James Bach
21. For Queries write to me at
surenethiraj@gmail.com
Linked In: in.linkedin.com/pub/surendran-ethiraj/5/946/a11
Notas do Editor
When to Use 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.
When testing JavaScript-heavy websites, at some point you may reach Selenium limits. A simple use case will fail. You will getElementNotVisibleException, even though you can clearly see that element. Other times the same selector will return different results depending on the type of the browser. Fortunately, a simple solution exists …. Selenium WebDriver 2.0 provides us an Interface ‘JavaScriptExecutor’ to execute JS/Jquery scripts independent or within the application Sample: JavascriptExecutor je = (JavascriptExecutor) webDriver(); String script ="document.getElementById('" + elementId + "').value = '" + textToEnter + "';"; je.executeScript(script);
It works by retrieving the “href” attribute of the link and get the http status code for that link. If the links are accessible then http return codes like 200, 201 and 202 Else if the links are broken then http return codes like 4XX, 5XX From the Http codes we could decide whether a specific link is broken or not.
Firebug wanted to have a export in its Net panel, which lead them to team up with HTTPWatch to produce a common format named ‘HAR’.
The data is stored as a JSON document and extracting meaning from the low level data is not always easy, but with practice, a HAR file can quickly help you identify the key performance problems with a web page, which in turn will help you efficiently target your development towards the areas that will deliver the greatest return on your efforts.