>>Dominik Dary: Thanks, Sonal.
So, yeah, I would like to talk about test automation on Android, and especially about
Selendroid.
My name is Dominik.
I'm working as an engineering manager at Adobe Hamburg.
And there we are creating a platform as a service called Shared Cloud.
It's used by various clients, like Creative Cloud and Marketing Cloud.
And the important thing is, this presentation is a presentation from the Selendroid community,
so the opinions expressed are my own.
The project Selendroid is available on GitHub and we write also documentation.
Our biggest committers are coming from eBay, from Salesforce, and also from Facebook.
And we have a committers meeting at IRC on Freenode.
So if you would like to join the conversation, feel free.
An important thing is, we are really a proper open source project, so there's no internal
version somewhere.
So we are really having everything in the public, so everything that you see is also
what we use.
And the reason why I created Selendroid two years ago was really there were some other
open source mobile automation frameworks available, but the issue was really that they were not
able to seamlessly automate native parts and webview parts.
And, yeah, there was something missing.
And that was the reason why I created Selendroid.
And you can automate native and hybrid mobile apps and can test the mobile Web on Android
from API 10 to 19.
So Android Lollipop, I executed the test on this operationing system, and most of the
tests are succeeding, but there is still some work that needs to be done.
Another thing that for us is very important, is that we are fully compatible with the JSON
Wire Protocol.
So last year in August, there was a meeting where we talked about the mobile WebDriver
spec and that is the spec that we currently fully support.
If there is something that we have added, any special features that are only available
for Selendroid, then we have marked them as json wire protocol extensions so that you
see, they're only available in Selendroid.
One important thing is that if you test automate a mobile app, it must not be modified.
That means you just get the app from your developers, and then if you write the automated
test, there is a small Selendroid server APK and the test app, and then the test.
And both get installed on the device.
The important thing, the only thing that gets changed is the app under test that gets resigned,
and then both get installed, and then it can be tested.
But that's the only thing that gets changed.
The devices must not be modified.
And another thing is that it can interact with multiple Android hardware devices, but
also with multiple emulators.
So that means that Selendroid can start your emulators.
And one of the benefits of doing this is, you can specify in the capabilities what kind
of locale you would like to have.
So that means if you run your test against multiple localizations, then Selendroid supports
you there.
You can also plug in hardware devices, they will be automatically detected by Selendroid.
This is pretty much interesting for you if you are running a device wall.
We support advanced user gestures.
So now I would like to show you how testing looks like.
First, that is a native app.
That's an app that we use to verify that actually Selendroid itself works fine.
And here we are finding a button by the ID.
And then we're clicking on it.
And the next step is that an activity gets started.
And there we are looking for an input field, also by ID.
And then we are verifying that a certain text is displayed there.
Then we're clearing the field and we're sending a new text.
So that's pretty much how we would expect it from WebDriver, and that it works.
The other thing is that there are multiple other locators supported, and they are all
documented on the Web site.
Hybrid Apps - So there is not much different.
The only thing that you need to know is, you need to switch your context.
So for default, Selendroid is talking to the native context.
But if you would like to route all the different commands to the WebView, you need to set the
context.
And then, yeah, if you find another element.
Here, in this case, we are using the Tag name “input“ to find it, then we're sending
some text, and then we're verifying it.
So that's something that, yeah, if you compare both of them, they are very similar.
And that's actually one of the powerful things about using WebDriver to do mobile automation.
And another thing that you can do as well because we're able to interacting with WebViews,
we are also able to test the mobile Web.
So we have added a special app that has only a WebView.
And we can do mobile testing there.
We call it AndroidDriver app.
And as you can see here, you can open, for example, the eBay Web page and then just search
for a Nexus 6 device.
With KitKat, you're able to use ChromeDriver to automate the Chrome browser.
But for earlier releases, Selendroid is the only way that you can use.
Another thing is that not all of the testers are Android developers.
So it's also important to support the Android testers that are writing tests for it.
And that's the reason why we created the Selendroid inspector.
So it helps you to inspect the view hierarchy.
You see exactly what kind of elements are displayed on the UI.
And the inspector is built in to Selendroid.
So it's just there.
You can just use it.
Then also the UI element properties are displayed, so you see, for example, the ID of the element,
the value, or the class name.
Then on the left-hand side, there is the screenshot displayed, and the screenshot shows you also
the hovered elements, and then you see automatically if it fits, so you see this yellow rectangle.
And that's really helpful.
Then the other thing is, there's a basic action to record the click actions.
So the intention is not to build a record and playback tool.
We all know it's not the right thing to do.
Especially for newbie testers, that's something that really helps them to get started.
So you see, then, here at the bottom a sample test code in Java that gets generated.
And the intention is really just to help newbies.
With KitKat, you're able to remotely debug the WebView, so there it's relatively easy
to grab the HTML of the WebView.
But before, it was really hard.
And that's also the reason why we built in the mechanism how you can grab the HTML of
the WebView and display it in the inspector.
And then for native support, sometime it's still needed to use XPath.
And there's a kind of helper tool to build in to validate that the XPath expression is
the right one.
So with that, we have also now built in multitouch support.
So I'm starting with a simple example using just one single finger.
So here I am just saying, okay, thinking of putting the finger down, then moving it, then
putting it up.
And then I'm just executing the action.
But also, you are able to execute multifinger actions.
So here, you see the first action with the first finger.
It's just the same kind of gesture, just finger down, moving, and putting it up.
And then defining the next finger action.
And then what I do here is that I define the multitouch action, and then using both fingers,
and then the action is just executed.
So that's now built in and available.
Another thing is very often that if you would like to automate your app, maybe there's some
special code that needs to be executed to bootstrap your app.
And one important thing is, we cannot build this into Selendroid, because, of course,
we are an open source project.
But if you would like to do it, we are offering a way how you can extend Selendroid at run
time.
That means there's a BasicRequestHandler.
And that one you can extend.
And the only thing that you need to do is that you need to build it, and then you have
to dex it.
And we have a project called Selendroid-Extension on our GitHub page where you see how that
actually works, what you need to do, how to set up Maven and so on.
If you have done this, you are able to write your automated test.
And in your automated test, you say, for example, that you would like to use your extension.
Then you are firing up the Selendroid driver.
And then you are able to call the extension by the full class name.
And then you get the result that you have specified.
And with that, you are able to execute specific actions, but also bootstrap your app.
That's, for example, heavily used at Facebook.
Now I talk mainly about how to automate the app and write tests for it and how Selendroid
can help to do that.
But on the other side, if you have written all the tests, it's also important to think
about how to execute them.
Of course, there are different providers that you can use to run the test on.
But if you are not allowed to do it and if you would like to know how to do it in your
company, you can use, for example, the Selenium Grid.
And the important thing is that for default, you have Selendroid server or you have a Selenium
server in general, and you have a client, and they both are talking to each other.
What you can do now is, you just put the Selenium Grid hub in between.
And with this, you are able to use multiple clients to talk to this, and Grid hub is acting
as a load balancer.
And now you are also able to add different nodes to the Selenium Grid hub.
And here you are able to plug in multiple Selendroid Nodes that have plugged in multiple
Android phones or different emulator configurations.
But you're also able to add, for example, iOS driver nodes if you want to test iOS applications.
So with that, you have also the tools to scale.
And one of the power of using Selenium-based automation is really that, in my previous
company, we have seen that it's very important also to write these cross-platform tests,
so users use different platforms.
So, for example, in the morning, they are using their Android phone to look something
up, and then at noon, they're buying something on the normal Web site.
And then in the evening, they're using their iPad to pay items.
And this kind of scenario, it's relatively easy to automate this with WebDriver, because
your tests are written in the same language and you have different servers on the right-hand
side, but on the left-hand side, you have always the same client API, and so it's relatively
easy to do that.
So and all the features I talked about, they are available at GitHub.
You can download them there.
And the documentation is also updated.
And, yeah, thank you very much.
And so if you would like to see how this works in action, there are some YouTube videos available,
and also there's a recently published article about what is the methodology behind it and
how it can be used.
So thank you very much.
[ Applause ] >>Alan Myrvold: I've got three questions from
the moderator.
How is the support from the Android team when you're developing Selendroid for newer versions?
>>Dominik Dary: Until now, we got no support.
>>Alan Myrvold: Okay.
[ Laughter ] Hopefully, we can improve on that.
Why is capture replay not the right thing to do?
Is it because it generates flaky tests?
And how can that be fixed?
>>Dominik Dary: Yeah.
So it's just a thing that -- it's a long story, so....
It's -- we just -- at my previous employer, we just made very, very bad experiences with
record and playback, because you're going through the app, you have exactly those steps,
but sometimes you need to have this explicit ways you need to add, and that's something
that the tool cannot be -- cannot do for you.
And so it's just a starting point that should help the testers.
>>Alan Myrvold: And then the last question: I know Selendroid means it's meant for Android.
But is there a way that you can leverage this for iOS devices as well?
>>Dominik Dary: So you cannot use it for iOS devices.
The only thing that we recommend is using iOS driver or sister Project.
>>> (Off mic.)
Does Selendroid support screenshots?
>>Dominik Dary: Yes.
So there are two options available.
You can take it onto the device, or using ddmlib.
>>> Cool.
Thanks.