Download presentation
Presentation is loading. Please wait.
Published byEugene Underwood Modified over 9 years ago
1
Dominik Dary Romanian Testing Conference 2015
Selendroid in Action Dominik Dary Romanian Testing Conference 2015
2
Who am I? Disclaimer: My Opinions are my own.
Dominik Dary Engineering Github: Disclaimer: My Opinions are my own. Selendroid in Action by Dominik Dary
3
Selendroid in Action by Dominik Dary
Agenda Short Introduction After covering the basics about how to find and interact with UI elements, we will look into techniques of writing maintainable tests. In the end of the workshop we will run our tests in parallel using the Selenium Grid. Selendroid in Action by Dominik Dary
4
Selendroid in Action by Dominik Dary
Prerequisits The workshop prerequisites are documented on the Selendroid homepage: Are we ready? Selendroid in Action by Dominik Dary
5
Selendroid in Action by Dominik Dary
Short Introduction Selendroid in Action by Dominik Dary
6
W3C WebDriver Spec JSON WIRE PROTOCOL Client Server Ruby Java Python
e.g. FirefoxDriver, Selendroid, ios-driver Server Selendroid - Supported Methods Selendroid in Action by Dominik Dary
7
One Protocol to rule them all
Source: Selendroid in Action by Dominik Dary
8
Selendroid in Action by Dominik Dary
Open sourced on github: Documentation: Committers: eBay, PayPal, Salesforce, Facebook, Red Hat and many others Getting help IRC : #selendroid on freenode Selendroid in Action by Dominik Dary
9
Selendroid in Action by Dominik Dary
Features The only mobile WebDriver that supports native & hybrid apps and testing the mobile web on Android versions (API 10 to 19) Full compatibility with the JSON Wire Protocol. The app under test must not be modified No jailbreak / rooting of devices Interacts simultaneously with multiple Android devices Supports hot plugging of hardware devices Advanced Gestures are supported Selendroid in Action by Dominik Dary
10
Selendroid in Action by Dominik Dary
Testing In Action Native Hybrid Mobile Web WebElement button = driver.findElement( By.id("startUserRegistration")); button.click(); WebElement nameInput = driver.findElement(By.id("inputName")); Assert.assertEquals( nameInput.getText(), "Mr. Burns"); nameInput.clear(); nameInput.sendKeys(“RTC 2015"); // Switch to the web view context driver.context("WEBVIEW"); String vpOfEngineering = "John Williams"; WebElement searchBox = driver.findElement(By.tagName("input")); searchBox.sendKeys(vpOfEngineering); driver.findElement( By.partialLinkText(vpOfEngineering)). click(); WebDriver driver = new RemoteWebDriver( DesiredCapabilities.android()); driver.get(" WebElement element = driver.findElement( By.id("kw")); element.sendKeys("Nexus 6"); element.submit(); Selendroid in Action by Dominik Dary
11
Native Element Selectors
Id Finds the element by Id. name Finds the element by content description (accessibility label). link text Finds the element by displayed text. partial link text Finds the element by partial displayed text. class Finds the element by full class name (e.g. android.widget.Button). tag name Finds the element by tag name e.g. button xpath Finds the element by a xpath expression. Selendroid in Action by Dominik Dary
12
Selendroid in Action by Dominik Dary
Selendroid Inspector View hierarchy View UI element properties UI screenshot with view locator Record the click actions View HTML of a web view XPath helper Demo: Selendroid in Action by Dominik Dary
13
Selendroid in Action by Dominik Dary
First Hands on Session Selendroid in Action by Dominik Dary
14
First Practical Session
Clone the project: Open Class: git clone FirstSelendroidTest Selendroid in Action by Dominik Dary
15
Selendroid in Action by Dominik Dary
FirstSelendroidTest Make sure you have defined an emulator (and started) or connected a hardware device. Excuting „adb devices“ lists your device The test automatically starts and stops selendroid Add a breakpoint Selendroid in Action by Dominik Dary
16
Selendroid in Action by Dominik Dary
Please Write a Test that navigates to the User Registration Screen Use the Selendroid Inspector to find the element details Use these locators Id, name, XPath, link text Goal is to fill out the registration form and To validate on the following Dialog that the right input Hints: Debug the test and use the Selendroid Inspector ( ) Docu is located here: Do not overengineer, just write all the steps Selendroid in Action by Dominik Dary
17
Selendroid in Action by Dominik Dary
Selendroid Repl Interactive Command execution Results are immediately displayed The app can be manually used to navigate to the dialog you want to automate. Interested? Read more: selendroid-workshop/docs/selendroid-python-repl.md Selendroid in Action by Dominik Dary
18
Maintainability is king
Selendroid in Action by Dominik Dary
19
Select Payment Provider
Pages and Flows Example e-Commerce Site Item Page Shopping Cart Page Checkout Page Success Page View Category Review Select Payment Provider Order Summary Search Item Update View Category View Orderlist View Product Delete Selendroid in Action by Dominik Dary
20
Selendroid in Action by Dominik Dary
In Our Example... Selendroid in Action by Dominik Dary
21
Selendroid in Action by Dominik Dary
Android App Test Case Tests Flow Objects Page Objects Selendroid in Action by Dominik Dary
22
Second Hands on Session
Selendroid in Action by Dominik Dary
23
git checkout resultFirstSession
Use Pages and Flows If you have not finished the first session, checkout the branch Please create a Page Object class for every screen Please create a flow class that delegates to the different pages Change your test in order to use the flow and page objetcs Run your tests git checkout resultFirstSession Selendroid in Action by Dominik Dary
24
git checkout resultSecondSession
Second Result If you have not finished the first session, checkout the branch git checkout resultSecondSession Selendroid in Action by Dominik Dary
25
Selendroid in Action by Dominik Dary
Test Infrastructure Selendroid in Action by Dominik Dary
26
The Importance of parallel Test Execution
Multiple Apps Multiple Locales iOS Devices iPhone vs. iPad Version Android Devices Manufactures Screen Sizes OS Modifications Picture Source: Selendroid in Action by Dominik Dary
27
Scaling using the Selenium Grid
Client server Client GRID Hub server CI server Selendroid in Action by Dominik Dary
28
Selendroid in Action by Dominik Dary
Third Hands on Session Selendroid in Action by Dominik Dary
29
Selendroid in Action by Dominik Dary
Startup a Grid Start Selenium Grid Start Selendroid and register to Grid java -Dfile.encoding=UTF-8 -cp "selendroid-grid-plugin SNAPSHOT.jar:selenium-server-standalone jar" org.openqa.grid.selenium.GridLauncher -capabilityMatcher io.selendroid.grid.SelendroidCapabilityMatcher -role hub -host your_ip -port 4444 java -jar selendroid-standalone SNAPSHOT-with-dependencies.jar -app selendroid-test-app SNAPSHOT.apk -port hub -proxy io.selendroid.grid.SelendroidSessionProxy -host your_ip Documentation: Selendroid in Action by Dominik Dary
30
Selendroid in Action by Dominik Dary
After you have started the grid Check if everything is fine: Selendroid Standalone: Grid: Selendroid in Action by Dominik Dary
31
Selendroid in Action by Dominik Dary
Change the Test Open any previous test Deactive Code that starts selendroid Use this Driver instantiation code: driver = new SelendroidDriver(new URL(" caps); Run your test Now your tests get executed using the Selenium Grid Selendroid in Action by Dominik Dary
32
Selendroid in Action by Dominik Dary
Recap Selendroid in Action by Dominik Dary
33
Selendroid in Action by Dominik Dary
Recap We used selendroid to automate a native Android app With different locators We optimized our code to use Page Objects And used the Selenium Grid to run Tests in parallel Selendroid in Action by Dominik Dary
34
W3C WebDriver Spec JSON WIRE PROTOCOL Client Server Ruby Java Python
e.g. FirefoxDriver, Selendroid, ios-driver Server Selendroid - Supported Methods Selendroid in Action by Dominik Dary
35
We are looking for contributors and
Selendroid in Action by Dominik Dary Image Source:
36
Thank You! Questions or Comments?
Selendroid in Action by Dominik Dary
37
Selendroid in Action by Dominik Dary
Contact & Getting help IRC : #selendroid on freenode Mailing List: Selendroid in Action by Dominik Dary
38
Selendroid in Action by Dominik Dary
Native Demo: Hybrid Demo: Mobile Web Demo: Selendroid Article: Selendroid in Action by Dominik Dary
39
Selendroid in Action by Dominik Dary
BACKUP Selendroid in Action by Dominik Dary
40
Selendroid in Action by Dominik Dary
Multi Touch Support Single finger example: TouchAction ta = new TouchActionBuilder().pointerDown(). pointerMove(x, y).pointerUp().build(); driver.getMultiTouchScreen().executeAction(ta); Multi finger example (these will be executed in parallel): TouchAction finger1 = new TouchActionBuilder().pointerDown().pause(100). TouchAction finger2 = new TouchActionBuilder().pointerDown().pause(100). pointerMove(x, y).pointerUp().build(); MultiTouchAction multiAction = new MultiTouchAction(finger1, finger2); driver.getMultiTouchScreen().executeAction(multiAction); Selendroid in Action by Dominik Dary
41
Touch Gestures Session
Start Selendroid Test App Press „Touch Actions“ Button This Activity can be used to try Touch Gestures Identified gestures will be displayed Selendroid in Action by Dominik Dary
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.