Upload
igor-khrol
View
643
Download
2
Embed Size (px)
DESCRIPTION
My speech at Selenium Conf 2014 http://confengine.com/selenium-conf-2014/schedule#session-217-info
Citation preview
Increase Selenium tests stability via JavaScript
Igor Khrolhttp://www.khroliz.com
About myself• Igor Khrol• QA Automation Team Lead at
Wargaming• >8 years in test automation• Dozens of projects• Engineer, trainer, consultant,
manager, speaker• Working experience with Selenium
>5 years• My blog: http://en.khroliz.com
Agenda
• Theory and some reasoning• Practical cases
Dependency between testing level and support
Support
Test count
Tech level
UI-tests are unstable
UI-tests are unstable
One of the reasons – modern user interfaces:– Complex– Asynchronous
Modern user interfaces are based on prepared and already made components
Modern user interfaces are based on prepared and already made components
Already made components could be less tested by ourselves
Custom components could be tested separately
Majority of modern UI has internal API
API benefits
• Build to interact with UI components• Synchronous (or there are methods to sync)
1. UI based on already made components2. Already made components could be left
untested or could be tested separately3. Components have its own API4. That API is more reliable than WebDriver API
Use JavaScript API instead of WebDriver
Life example
User interface characteristics:• Lots of frames• ActiveX
Initial solution
driver.findElement(By.id(“fancy-id”)).click();
Browser
WebDriver API
Difficulties
• Interface is very asynchronous, methods work unstably
• Lots of frames (more than five nested) – hard to reach required control
• Impossible to work with ActiveX
Browser Script API
http://docs.oracle.com/cd/B40099_02/books/OIRef/OIRefBrowseScript.html
Browser Script HTTP Server Script
Examples
Final result
• Quick• Reliable• Synchronous
Problems
Synchronous methods and Alert
• Method call is not finished while Alert is not closed
• alert.accept() can’t be called as previous command is not finished yet
window.setTimeout
Lost 100% end user simulation
Other cases for such approach
jQuery based sites - 60%
Synchronization
Convert jQuery objects to WebElement and vise versa
Find elements
Get parent element
Ease interaction with complex elements
Calendar Thanks to @barancev
Custom controls
Custom controls
Common schema
Web Server
Browser
HTTP
Tests
Visible UI
Library
API Components
Core
WebDriver API
WebDriver APIJavaScriptExecutor
Temporary workaround existing WebDriver issues
Workaround wisely
• Only temporary workaround• Important to understand why standard
approach doesn’t work
Summary• Digging into technical details allows writing more
reliable tests• Learning JavaScript and UI-libraries – natural next
step for UI test automation• But we have to understand what we are missing
and find balance
Igor Khrolhttp://[email protected] / [email protected]
Thank you!Questions?