diff --git a/.gitignore b/.gitignore index b7e2314ee..a9c4cf5c4 100644 --- a/.gitignore +++ b/.gitignore @@ -9,4 +9,6 @@ test/data/output test/acceptance/output examples/output test/data/app/db -test/data/sandbox/steps.d.ts \ No newline at end of file +test/data/sandbox/steps.d.ts +testpullfilecache* +.DS_Store diff --git a/.travis.yml b/.travis.yml index 15821580a..cbc1b32b0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,38 +1,34 @@ language: node_js node_js: - - '4.3' - - '6.9.5' - - '7' - - +- 6.9.5 +- '7' sudo: required dist: trusty - env: + global: + - secure: vLPyF/U+KhmWAXMkcrYFben6Qo5Tsk9nExbb/YTxCCqtpu5FlCcKZ0h/7OXJT9sXR7t8dmz564VbAtbhazPU+2FdpxIoR/D6OUeZa1WhyB5GGfpfHmfIe1hQTsZg0B0zGrrpcLBeaTA1E7+0lBhIKj9S1FoApa6xfP21bju+IddpD881m0bdF/2gEiBrabWHoQieWLNgS4EzUI5IcOknz4bk3nx6ztldJOokwTqUy2RgtVbMkJf0v6LbBOxT5uCwlLYxllDwY6fIatPP7Gol5V2fxMYhp4k/QSeULy81EJBpVhW0Bw5FfGBBVnqk495fhCjRNbjwzcs2zz2dD1i99KeIFhfKYQsfto7odHbt0kasYgaQQUZEZsbY6ScYMDXnzprTCotolmPXJmqu0rHnUfa2ZZxl9/jNis1IoCdwsvJ+cemL13fw9llFvnMGtmqDc9ltjzKoRfi8rpUH5x6EbnUE6vdr0RDA+D3mUbFr2kxlMwQPTpujnxOghpuDnDc/2CGe17uklssw2g2vMxdIuiqxXvKkeN0xBddtlbUx2PwRrecjCmv7RE13j+ERsIysDQUkTMnXTWBumtVGmdxZpFhxD7wwmVFi3qjq4FGyO3f8alnfYOBspPhLgC2PTJGS/X23C9LC08tFl6MpeHD97HUaW6bx+ObI2/0jBsDXB3k= + - secure: OlLkzBUwlRFIa5xDWEs/It6ofSfC+pXRVt17kTyox8beH5qu5Ks3/Zwa48YMqHKnbNHI7hiRBO2YfsJgjYJoQ5/ovKPa3rvffNXdKeDZpt+lQqlhjJYpgp0pNgck45RKnFj1pKpQCVG6dWWcT59Gi8NoI8AsAVCVgFtO8McfV8qbks6G2UP0GdFR5s6tRyZTjfCVmMNtJX9veYuibwoiwRyFhh1FY+sw5BvAONSBdOWmcK7RdDm7IE+Oitzn3bRZnC6sgLNpy6qhncED/pbn4GFD5MRlu0UkDGDfXldsOyjOtqdaN5WbOGdhevaYgr/5VvSeMbO7fITlDXbhz9pViogl6fnxj0zELZvG6b6H7nAVV29uzHP4jofocP41h33rvYnQUTfNHN8HIRN4LVfekN2I27GDO+J1QFiWNN/36nhsRH9tWPwSNC2f9QLIf6OrD60FVUIMlQrFHqyrO4KZBZkRsGMgYzsa5XmGOGUATUBrmQVTynNQc+yhniJd4Q8LwwmXMDWNeoeg5eh0TFgERVDlkQ8tPaWOXmpHi6BL4JZlGz275SDWgZH4bnH2B1RzO1qcGN905vIo5snX8LwZbxSfXrt+4WP3jOi+1i8ZrFwACk7jlovJiJquQuZQ5dL7C9rBwpAWB8YjgOKNikDWvUrVnYGS/gLwrdN7+pRiims= + matrix: - HELPER=Protractor - HELPER=Nightmare - HELPER=SeleniumWebdriver - HELPER=WebDriverIO - + - HELPER=Appium addons: apt: packages: - - php5-cli - + - php5-cli services: - - docker - +- docker before_install: - - docker pull selenium/standalone-chrome:2.53.0 - +- docker pull selenium/standalone-chrome:2.53.0 before_script: - - docker run -d --net=host selenium/standalone-chrome:2.53.0 - - export DISPLAY=:99.0 - - sh -e /etc/init.d/xvfb start - - chmod -R 777 test/data - - "php -S 127.0.0.1:8000 -t test/data/app >/dev/null 2>&1 &" - - sleep 10 - +- docker run -d --net=host selenium/standalone-chrome:2.53.0 +- export DISPLAY=:99.0 +- sh -e /etc/init.d/xvfb start +- chmod -R 777 test/data +- php -S 127.0.0.1:8000 -t test/data/app >/dev/null 2>&1 & +- sleep 10 script: - - gulp test - - '[[ "$TRAVIS_NODE_VERSION" == "4.3" ]] || ./node_modules/.bin/mocha test/helper/${HELPER}_test.js' \ No newline at end of file +- gulp test +- './node_modules/.bin/mocha test/helper/${HELPER}_test.js' diff --git a/docs/helpers/Appium.md b/docs/helpers/Appium.md new file mode 100644 index 000000000..63dd4bb15 --- /dev/null +++ b/docs/helpers/Appium.md @@ -0,0 +1,1611 @@ +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 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 `