From 1686fa71d044829cbeca83058b50c5e700a1da1c Mon Sep 17 00:00:00 2001 From: Davert Date: Sun, 4 Jun 2017 01:58:25 +0300 Subject: [PATCH 1/2] updated Appium documentation, removed Appium from travis.yml --- .travis.yml | 1 - docs/helpers/Appium.md | 1587 +++++++---------------------------- docs/helpers/WebDriverIO.md | 230 +++-- lib/helper/Appium.js | 350 +++++++- test/helper/Appium_test.js | 4 +- 5 files changed, 746 insertions(+), 1426 deletions(-) diff --git a/.travis.yml b/.travis.yml index cbc1b32b0..645e172fe 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,7 +13,6 @@ env: - HELPER=Nightmare - HELPER=SeleniumWebdriver - HELPER=WebDriverIO - - HELPER=Appium addons: apt: packages: diff --git a/docs/helpers/Appium.md b/docs/helpers/Appium.md index 63dd4bb15..99cc56237 100644 --- a/docs/helpers/Appium.md +++ b/docs/helpers/Appium.md @@ -1,1611 +1,588 @@ -Appium helper is extends from WebriverIO. It's support all browser methods and also includes special methods for mobile apps testing. You can use this helper to test Web on desktop and mobile devices and mobile apps. +# Appium -#### Appium Installation - -Appium is an open source test automation framework for use with native, hybrid and mobile web apps that implements the WebDriver protocol. -It allows you to run Selenium tests on mobile devices and also test native, hybrid and mobile web apps. - -1. Download and install [Appium](http://appium.io/) - - ``` - npm i -g appium - ``` -2. Download and install Android SDK or Android Studio to manage emulators from [Android Studio site](https://developer.android.com/studio/index.html#downloads) -3. Set the $ANDROID_HOME env variable to your Android SDK path - - Example: - ``` - export ANDROID_HOME=/Users/bestUser/Library/Android/sdk - ``` -4. Add Android SDK tools to $PATH - - Example: - ``` - export PATH="${ANDROID_HOME}/tools:$PATH" - export PATH="${ANDROID_HOME}/tools/bin:$PATH" - ``` -5. Add Java Home bin directory to $PATH - - Example: - ``` - export PATH="${JAVA_HOME}/bin:$PATH" - ``` -6. Create and launch emulator: - - From Android Studio: - * Create any empty android application - * Create emulator using this [documentation](https://developer.android.com/studio/run/managing-avds.html) - * Note that x86 emulators works much faster as ARM emulators, but you can use them only on Mac and Linux. - * Launch emulator from interface - - From Command line: - * Create emulator using [avdmanager commandline tool](https://developer.android.com/studio/command-line/avdmanager.html) - * Launch emulator using [emulator commandline tool](https://developer.android.com/studio/run/emulator-commandline.html) -7. Test that Appium is installed correctly using `appium-doctor` - - ``` - npm i -g appium-doctor - appium-doctor - ``` - If there are any issues, you have to fix them before Appium launch - -8. Launch the daemon: `appium` -9. Also on Mac you can launch tests for iOS devices. For this, install xcode from App store. You can get detailed information [here](http://appium.io/slate/en/master/?ruby#running-appium-on-mac-os-x) - - - -### Configuration - -This helper should be configured in codecept.conf.js - -#### Appium configuration - -- `port`: Appium server port -- `restart`: restart browser or app between tests (default: true), if set to false cookies will be cleaned but browser window will be kept and for apps nothing will be changed. -- `desiredCapabilities`: Appium capabilities --- `platformName` - Which mobile OS platform to use --- `appPackage` - Java package of the Android app you want to run --- `appActivity` - Activity name for the Android activity you want to launch from your package. --- `deviceName`: The kind of mobile device or emulator to use --- `platformVersion`: Mobile OS version --- `app` - The absolute local path or remote http URL to an .ipa or .apk file, or a .zip containing one of these. Appium will attempt to install this app binary on the appropriate device first. --- `browserName`: Name of mobile web browser to automate. Should be an empty string if automating an app instead. - -Example: - -```js - { - helpers: { - Appium: { - desiredCapabilities: { - platformName: "Android", - appPackage: "com.example.android.myApp", - appActivity: "MainActivity", - deviceName: "OnePlus3", - platformVersion: "6.0.1" - }, - port: 4723, - restart: false - } - } - } -``` -Additional configuration params can be used from - - -## Access From Helpers - -Receive a Appium client from a custom helper by accessing `browser` property: - -```js -this.helpers['Appium'].browser -``` - -**Parameters** - -- `config` - -## _locate - -Get elements by different locator types, including strict locator -Should be used in custom helpers: - -```js -this.helpers['Appium']._locate({name: 'password'}).then //... -``` - -**Parameters** - -- `locator` - -## _locateCheckable - -Find a checkbox by providing human readable text: - -```js -this.helpers['Appium']._locateCheckable('I agree with terms and conditions').then // ... -``` - -**Parameters** - -- `locator` - -## _locateClickable - -Find a clickable element by providing human readable text: - -```js -this.helpers['Appium']._locateClickable('Next page').then // ... -``` - -**Parameters** - -- `locator` - -## _locateFields - -Find field elements by providing human readable text: - -```js -this.helpers['Appium']._locateFields('Your email').then // ... -``` - -**Parameters** - -- `locator` - -## acceptPopup - -Accepts the active JavaScript native popup window, as created by window.alert|window.confirm|window.prompt. -Don't confuse popups with modal windows, as created by [various libraries](http://jster.net/category/windows-modals-popups). - -Appium: support only web testing - -## amOnPage - -Opens a web page in a browser. Requires relative or absolute url. -If url starts with `/`, opens a web page of a site defined in `url` config parameter. - -Appium: support only web testing - -```js -I.amOnPage('/'); // opens main page of website -I.amOnPage('https://github.com'); // opens github -I.amOnPage('/login'); // opens a login page -``` - -**Parameters** - -- `url` url path or global url - -## appendField - -Appends text to a input field or textarea. -Field is located by name, label, CSS or XPath - -Appium: support, but it's clear a field before insert in apps - -```js -I.appendField('#myTextField', 'appended'); -``` - -**Parameters** - -- `field` located by label|name|CSS|XPath|strict locator -- `value` text value - -## attachFile - -Attaches a file to element located by label, name, CSS or XPath -Path to file is relative current codecept directory (where codecept.json is located). -File will be uploaded to remote system (if tests are running remotely). - -Appium: not tested - -```js -I.attachFile('Avatar', 'data/avatar.jpg'); -I.attachFile('form input[name=avatar]', 'data/avatar.jpg'); -``` - -**Parameters** - -- `locator` field located by label|name|CSS|XPath|strict locator -- `pathToFile` local file path relative to codecept.json config file - -## cancelPopup - -Dismisses the active JavaScript popup, as created by window.alert|window.confirm|window.prompt. - -Appium: support only web testing - -## checkOption - -Selects a checkbox or radio button. -Element is located by label or name or CSS or XPath. - -Appium: support only web testing - -The second parameter is a context (CSS or XPath locator) to narrow the search. - -```js -I.checkOption('#agree'); -I.checkOption('I Agree to Terms and Conditions'); -I.checkOption('agree', '//form'); -``` - -**Parameters** - -- `field` checkbox located by label | name | CSS | XPath | strict locator -- `context` (optional) element located by CSS | XPath | strict locator - -## clearCookie - -Clears a cookie by name, -if none provided clears all cookies - -Appium: support only web testing - -```js -I.clearCookie(); -I.clearCookie('test'); -``` - -**Parameters** - -- `cookie` (optional) - -## clearField - -Clears a `