forked from selendroid/selendroid.io
-
Notifications
You must be signed in to change notification settings - Fork 0
/
quickStart.html.haml
196 lines (170 loc) · 9.75 KB
/
quickStart.html.haml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
---
layout: base
title: Quick Start
author: Dominik Dary
---
.container-fluid
.row-fluid
.span3
#sidebar
%ul.nav.nav-tabs.nav-stacked
%li
%a{:href=>'#beforeStart'} Before you start
%li
%a{:href=>'#withMaven'} Use Selendroid with Maven
%li
%a{:href=>'#nativeAppTest'} Native App Test
%li
%a{:href=>'#hybridAppTest'} Hybrid App Test
%li
%a{:href=>'#mobileWebTest'} Testing the mobile Web
%li
%a{:href=>'#usingOtherClientBindings'} Writing Tests in other languages
.span9
%script{ :type=>'text/javascript', :src=>'./javascripts/github-files.js' }
%h1 Quick Start
%p This page demonstrates about how to get started with the demo project for testing native and hybrid apps and the mobile web. The demo project is located at Github: <a href="https://github.com/selendroid/demoproject-selendroid">https://github.com/selendroid/demoproject-selendroid</a>
%h2#beforeStart Before you start
%p To get started please <a href="#{site.setup_page}#systemRequirements">setup first your system</a> and if you want to use an emulator during test, please checkout <a href="#{site.setup_page}#androidDevices">this section</a>.
%h2#withMaven Use Selendroid with Maven
%p The demo project is based on <a href="http://maven.apache.org/">Apache Maven</a> and uses <a href="http://junit.org/">JUnit 4</a> to run the tests.
%h3 Maven Central (Stable Version)
%p Selendroid is available in Maven central can be added in the <em>dependencies</em> section of the <code>pom.xml</code>:
%pre
%code.xml
= preserve do
:escaped
<dependency>
<groupId>io.selendroid</groupId>
<version>#{site.current_version}</version>
<artifactId>selendroid-standalone</artifactId>
</dependency>
<dependency>
<groupId>io.selendroid</groupId>
<version>#{site.current_version}</version>
<artifactId>selendroid-client</artifactId>
</dependency>
%h3 Latest Snapshot version
%p Selendroid latest development version is available in a Maven snapshot repo. For using the latest version, please add in the <em>dependencies</em> section of the <code>pom.xml</code>:
%pre
%code.xml
= preserve do
:escaped
<dependency>
<groupId>io.selendroid</groupId>
<version>#{site.snasphot_version}</version>
<artifactId>selendroid-standalone</artifactId>
</dependency>
<dependency>
<groupId>io.selendroid</groupId>
<version>#{site.snasphot_version}</version>
<artifactId>selendroid-client</artifactId>
</dependency>
%p Please add as well in the <em>repositories</em> section of the <code>pom.xml</code> the following repository:
%pre
%code.xml
= preserve do
:escaped
<repository>
<id>snapshot</id>
<name>snapshot repository</name>
<url>https://oss.sonatype.org/content/repositories/snapshots/</url>
<layout>default</layout>
<snapshots>
<enabled>true</enabled>
</snapshots>
<releases>
<enabled>false</enabled>
</releases>
</repository>
%p Before starting <code>SelendroidDriver</code> it is mandatory to start the <code>SelendroidStandalone</code>-server. This can be done by
%ul
%li using the command line or
%li code in the test case
%h3 Command line start of selendroid-standalone
%p Go through Selendroid's <a href="#{site.setup_page}">setup instructions</a> and download the current version. The applications that are we are using in the demo project are located in <a href="https://github.com/selendroid/demoproject-selendroid/tree/master/src/main/resources">this folder</a>.
%p To start the standalone server please open your prefered shell and run:
%code java -jar selendroid-standalone-#{site.current_version}-with-dependencies.jar -aut EmployeeDirectory.apk -aut selendroid-test-app-#{site.current_version}.apk
%p When the server is started you can verify the current configuration <a href="http://localhost:4444/wd/hub/status">http://localhost:4444/wd/hub/status</a>:
%pre
%code.json
= preserve do
:escaped
"supportedApps":[
{
"appId":"io.selendroid.directory:0.0.1",
"mainActivity":"io.selendroid.directory.EmployeeDirectory",
"basePackage":"io.selendroid.directory"},
{
"appId":"io.selendroid.testapp:#{site.current_version}",
"mainActivity":"io.selendroid.testapp.HomeScreenActivity",
"basePackage":"io.selendroid.testapp"
}
]
%h3 Start selendroid-standalone during test
%p Before the test is executed the selendroid-standalone server will be started:
%pre
%code.java
= preserve do
:escaped
SelendroidConfiguration config = new SelendroidConfiguration();
// Add the selendroid-test-app to the standalone server
config.addSupportedApp("src/main/resources/selendroid-test-app-#{site.current_version}.apk");
selendroidServer = new SelendroidLauncher(config);
selendroidServer.launchSelendroid();
%p The test itself you find <a href="https://github.com/selendroid/demoproject-selendroid/blob/master/src/main/java/io/selendroid/demo/SelendroidIntegrationTest.java#L45">here</a>.
%h2 Tests
%p After the <code>selendroid-standalone</code> has been started, the <code>SelendroidDriver</code> can be initialized:
%pre
%code.java
= preserve do
:escaped
// Create the selendroid capabilities and specify to use an emulator and selendroid's test app
SelendroidCapabilities caps = new SelendroidCapabilities("io.selendroid.testapp:#{site.current_version}");
driver = new SelendroidDriver(caps);
%p The capabilities are describing what app is used for testing and in this example the selendroid test app is used.
%h2 Simple Tests
%p For testing the Android app the <a href="http://docs.seleniumhq.org/docs/03_webdriver.jsp">WebDriver API</a> is used. This demonstrates about how a text field can be found and text can be entered.
%pre
%code.java
= preserve do
:escaped
// Find an element by id
WebElement inputField = driver.findElement(By.id("my_text_field"));
//enter a text into the text field
inputField.sendKeys("Selendroid");
//check if the text has been entered into the text field
Assert.assertEquals("Selendroid", inputField.getText());
%h2#nativeAppTest Native App Test
%p Selendroid's <a href="https://github.com/selendroid/demoproject-selendroid/blob/master/src/main/resources/selendroid-test-app-0.10.0.apk">test app</a> contains an user registration flow that will be tested in the <a href="https://github.com/selendroid/demoproject-selendroid/blob/master/src/main/java/io/selendroid/demo/nativeui/UserRegistrationTest.java">UserRegistrationTest</a>:
%pre
%code#nativeCode.java
= preserve do
:escaped
%script
$.getGithubFile("selendroid", "demoproject-selendroid", "461779eef28f4c8f09ffbc8ff6aa4a0c1c531106", function(contents) {$('#nativeCode').html(contents);},14);
%p The test demonstrates how activities can be started and how the interaction with different elements can be done.
%h2#hybridAppTest Hybrid App Test
%p Selendroid can be used to test hybrid applications. The project contains a <a href="https://github.com/selendroid/demoproject-selendroid/blob/master/src/main/resources/employee-directory.apk">Cordova sample app</a> and the <a href="https://github.com/selendroid/demoproject-selendroid/blob/master/src/main/java/io/selendroid/demo/webui/EmployeeDirectoryTest.java">EmployeeDirectoryTest</a>:
%pre
%code#hybridCode.java
= preserve do
:escaped
%script
$.getGithubFile("selendroid", "demoproject-selendroid", "f901c7825028fcc7ba4613021f809e03f48b559b", function(contents) {$('#hybridCode').html(contents);},14);
%h2#mobileWebTest Testing the mobile Web
%p Selendroid supports with version 0.7.0 testing the mobile web. The sample project contains a <a href="http://goo.gl/2iLiKj">MobileWebTest</a> example:
%pre
%code#mobileWebCode.java
= preserve do
:escaped
%script
$.getGithubFile("selendroid", "demoproject-selendroid", "53856b48a63811da410ea4db6f545f27d34427ce", function(contents) {$('#mobileWebCode').html(contents);},14);
%h2#usingOtherClientBindings Writing Tests in other languages
%p Tests can be written in every programming language a Selenium client binding is available. A simple JUnit based python tests you can find <a href="https://github.com/selendroid/demoproject-selendroid/blob/master/src/main/python/FindElementTest.py">here</a>:
%pre
%code#pythonSampleCode.python
= preserve do
:escaped
%script
$.getGithubFile("selendroid", "demoproject-selendroid", "59ea343562ae63d9f358d31f1a1628b484f150da", function(contents) {$('#pythonSampleCode').html(contents);},4);