You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Jan 19, 2025. It is now read-only.
*In this post I will talk about how to use Appium to write cross platform end to end tests.*
14
+
*In this post I will talk about how to use Appium to write cross platform end to end tests for you mobile apps..*
15
15
16
16
---
17
17
18
-
During my daily job I'm used to write unit test for my code. In fact, I usually develop using [Test Driven Development]() technique. Anyway at the end of the development of a new feature you want to be sure that everything you developer works as expected. In particular, you want to test the entire new feature flow inside the app. This is usually what is called [end to end test]().
19
-
In the last few months the mobile team "team cook" at [lastminute.com group](), of which I'm a member, decided to put in place an end to end testing infrastructure for the mobile apps of our main brand [lastminute.com](https://lmgroup.lastminute.com/), [volagratis](https://www.volagratis.com/) and [rumbo](https://www.rumbo.es/). In this post I will described this testing infrastructure and how it works.
18
+
During my daily job I'm used to write unit test for my code. In fact, I usually develop using [Test Driven Development](https://en.wikipedia.org/wiki/Test-driven_development"TDD") technique. Anyway at the end of the development of a new feature you want to be sure that everything you developer works as expected. In particular, you want to test the entire new feature flow inside the app. This is usually what is called [end to end test](https://www.techopedia.com/definition/7035/end-to-end-test"end to end tests").
19
+
In the last few months the mobile team "Team Cook" at [lastminute.com group](https://lmgroup.lastminute.com/"lastminute.com group"), of which I'm a member, decided to put in place an end to end testing infrastructure for the mobile apps of our main brand [lastminute.com](https://www.lastminute.com/), [volagratis](https://www.volagratis.com/) and [rumbo](https://www.rumbo.es/). In this post I will described this testing infrastructure and how it works.
20
20
21
21
#### **Software**
22
22
To put in place the e2e infrastructure we choose:
@@ -29,10 +29,11 @@ To put in place the e2e infrastructure we choose:
29
29
-[babel](https://github.com/babel/babel"babel es6"), is a compiler for writing next generation JavaScript
30
30
-[Appium XCUITest Driver](https://appium.io/docs/en/drivers/ios-xcuitest/index.html"appium ios driver") for iOS
31
31
-[Appium UiAutomator Driver](https://appium.io/docs/en/drivers/android-uiautomator2/index.html"appium android driver") for Android
The first thing we did was installing all the above software on our CI machine. As a consequence of the fact that we want to run tests for both iOS and Android a macOS based CI machine is needed (because you need to install Xcode). Fortunately, our CI machine was already an Apple Computer so we didn't need to change anything.
35
-
After that we created a new javascript project that follows the structure of the [WebdriverIO sample code contained in the Appium github repository](https://github.com/appium/appium/tree/master/sample-code/javascript-webdriverio"appium webdriverio sample"). This sample project is written using ES5 syntax, so we decided to upgrade to use ES6 syntax and compile it using Babel. This is possible by launching mocha and specifing babel as the compiler. This is the final command to launch our tests:
36
+
After that we created a new javascript project, that we called `e2e-tests`, that follows the structure of the [WebdriverIO sample code contained in the Appium github repository](https://github.com/appium/appium/tree/master/sample-code/javascript-webdriverio"appium webdriverio sample"). This sample project is written using ES5 syntax, so we decided to upgrade to use ES6 syntax and compile it using Babel. This is possible by launching mocha and specifing babel as the compiler. This is the final command to launch our tests:
36
37
37
38
```shell
38
39
mocha --compilers js:babel-core/register --timeout 6000000 test
@@ -106,7 +107,7 @@ const androidConfig = {
106
107
export {iOSConfig, androidConfig}
107
108
```
108
109
109
-
One important thing to note about the configuration above is that for iOS we were forced to set the following for options:
110
+
One important thing to note about the configuration above is that for iOS we were forced to set the following four options:
110
111
111
112
```javascript
112
113
wdaStartupRetryInterval:1000,
@@ -115,4 +116,13 @@ waitForQuiescence: false,
115
116
shouldUseSingletonTestManager:false,
116
117
```
117
118
118
-
This were need in order to avoid a [know bug in appium for iOS](https://github.com/appium/appium/issues/9645) that causes the appium test suite be get stuck on iOS during the creation of the appium webdriver session.
119
+
These were need in order to avoid a [know bug in appium for iOS](https://github.com/appium/appium/issues/9645) that causes the appium test suite to get stuck during the creation of the appium WebdriverIO session.
120
+
After the configuration setup we were ready to write our first tests. To write them we used the [Appium desktop app](https://github.com/appium/appium-desktop"Appium desktop app") to record the interfaction with our apps. The outcome of the recording is a test source code written in the language + driver you prefer (in our case JavaScript + WebdriverIO). Remember that appium uses the accessibility id on iOS and the content-desc on Android to unify the search method for both platform. If this fields are not setted correctly with the UI elements you interact with, the appium desktop app will generate a XPath queries for XCUITest or UiAutomator. This will cause you to write two tests with the same interaction just to change the UI elements identifier (or write some wrapper with parametrized UIElements). So the best solution to have appium works correctly is to set the fields above with the same values on both iOS and Android.
121
+
After that we launched the appium server on the CI machine previously configured and we created a new Jenkins job that clones the `e2e-tests` project and runs the command:
122
+
123
+
```shell
124
+
npm run test
125
+
```
126
+
127
+
This job is autmatically triggered (cron) every day at 8 PM.
128
+
Tha's all for appium and mobile end to end tests. If you have any question don't hesitate to comment on this post below :sparkling_heart:.
0 commit comments