Testers have all heard of Selenium and have used it to test web sites. It’s the de facto standard in writing automated tests and most browsers have either incorporated drivers into their builds or provided separate drivers that allow Selenium to interact with the browser. But what about Appium? It’s using the Selenium JSON wire protocol, so users should just be able to point their tests at an Appium server, right? During this SauceCon 2018 talk, Sergio Neves Barros will discuss the (historical) challenges of mobile web testing, platform differences between Appium and its drivers and Selenium, some of the additional endpoints/features Appium provides, the common features between Appium and Selenium, and discuss the future of mobile testing.
2. March 2018
1. About us
2. Selenium overview
3. Historical challenges
4. Platform overviews
5. Additional endpoints
6. Future of (mobile) web testing
Overview
3. March 2018
About us
Myself:
● 15 years of testing experience
● Insurance, Banking and Gaming.
● Dutch and moved to the UK in 2006
● Started with Gamesys over 5 year ago.
Gamesys:
● Virgin Games, Tropicana Casino, Jackpotjoy, Sun Bingo
● Slots, Bingo and Poker
● Technologies: HTML5, Canvas, Flash, Android, iOS, Web
Services
5. March 2018
How does selenium do its web magic?
How does selenium find a web element
How does it get an attribute
How does it click on the web element?
No not “protons, neutrons, and electrons”, but
javascript scripts called atoms.
NOTE: not every action requires atoms (e.g. navigate)
6. March 2018
How do atoms work?
Find Element example:
(<find-element-atom.js>)("id", "element-id")
response:
"{"status":0,"value":{"ELEMENT":":wdc:1518519286442"}}"
storage:
document.$wdc_
7. March 2018
How do atoms work (continued)?
click example:
(<click-element-atom.js>)({"ELEMENT":":wdc:1518520215151"})
get-attribute example:
(<get-attribute.js>)({"ELEMENT":":wdc:1518520215152"}, "<attribute-name>"))
Lets see them in
action.
8. March 2018
So how do we execute the atoms?
How does appium send the atoms to the browser and how does it retrieve
the response?
Remote Debugging Protocols!
It obviously can’t CTRL+C, CTRL+V like I just did.
11. March 2018
Historical Appium challenges (in 2013)
• Unable to run web tests on Safari on physical devices
• No/little support for remote debugging on mobile browsers
• No easy access to browsers on physical devices
• No ability to launch/close Safari on iOS devices
• Not all features were (yet) covered by Appium
• API was not fully defined (and constantly changing)
• No appium Java client.
Back in the day everything used to be better … uhh, well no.
12. March 2018
Challenge: Safari on a physical device
My question (April 2013):
“I am trying to grab the window_handles on the WebViewApp and this is working
fine on a iPhone simulator, however it's throwing an unhandled exception
on a real device”
ios-webkit-debug-proxy:
Luckily someone had already figured a way to forward requests to a physical device
and we just connected the dots (Appium - Pull Request 562 – for a laugh ).
Jonathan Lipps:
“This is unfortunately expected. Webview support works by creating a TCP connection
to the remote webkit debugger run in Safari/webviews. Even though
the real device might be running a webkit debugger, it's almost
definitely not forwarding that port to the host, where appium is running.
Someone will need to figure out how to reverse engineer the USB debugging
protocol and forward the port from the device to the host---
sounds like it will be challenging at best and maybe impossible at worst.”
13. March 2018
Challenge: Launching safari on a
deviceCan we use Instruments?
Can we use remote debugging?
Safari Launcher app
● Just navigate to a url and forces iOS to open Safari
● Add “--real-safari” argument when running reset.sh (build safari launcher with default profile)
● To build & install safari you will need a valid development profile
Can we use … an app?
14. March 2018
Challenge: Closing tabs on safari
Can we use javascript?
Can we use remote debugging?
Can we use Instruments?
Or can they ?
window.open('','_self').close();
17. March 2018
WebInspector vs WebKit protocol
WebInspector protocol wraps the Webkit protocol messages in an
“envelope” and adds additional fields (such as ApplicationIdenitifier,
PageIdentifier, SenderKey, ConnectionIdentier).
So if we use the Runtime.evaluate example, these fields will tell the
web inspector, which app and page it should execute the script on.
22. March 2018
Additional endpoints
Mobile JSON wire Protocol (DRAFT):
• Touch Actions (Tap, Swipe, Pinch)
WebDriver Protocol Extensions:
• Install/Uninstall App, Launch/Close app
• Get Performance Data (Android)
• CPUInfo
• MemInfo
There are many more.