Skip to content

fix: appium helper docs update #3966

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Nov 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
name: Appium Tests
name: Appium V2 Tests - Android

on:
push:
branches:
- 3.x
- feat/appium-is-app-installed
- appium-v1-deprecation

env:
CI: true
Expand Down
59 changes: 59 additions & 0 deletions .github/workflows/appiumV2_iOS.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: Appium V2 Tests - iOS

on:
push:
branches:
- 3.x
- appium-v1-deprecation

env:
CI: true
# Force terminal colors. @see https://www.npmjs.com/package/colors
FORCE_COLOR: 1

jobs:
appium1:
runs-on: ubuntu-20.04

strategy:
matrix:
node-version: [16.x]

steps:
- uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- run: npm install --legacy-peer-deps
env:
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: true
PUPPETEER_SKIP_CHROMIUM_DOWNLOAD: true
- run: 'npm run test:ios:appium-quick'
env: # Or as an environment variable
SAUCE_ACCESS_KEY: ${{ secrets.SAUCE_ACCESS_KEY }}
SAUCE_USERNAME: ${{ secrets.SAUCE_USERNAME }}


appium2:

runs-on: ubuntu-20.04

strategy:
matrix:
node-version: [16.x]

steps:
- uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- run: npm install --legacy-peer-deps
env:
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: true
PUPPETEER_SKIP_CHROMIUM_DOWNLOAD: true
- run: 'npm run test:ios:appium-other'
env: # Or as an environment variable
SAUCE_ACCESS_KEY: ${{ secrets.SAUCE_ACCESS_KEY }}
SAUCE_USERNAME: ${{ secrets.SAUCE_USERNAME }}
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,14 @@

Build Status:

Appium Helper:
[![Appium V2 Tests - Android](https://github.com/codeceptjs/CodeceptJS/actions/workflows/appiumV2_Android.yml/badge.svg)](https://github.com/codeceptjs/CodeceptJS/actions/workflows/appiumV2_Android.yml)
[![Appium V2 Tests - iOS](https://github.com/codeceptjs/CodeceptJS/actions/workflows/appiumV2_iOS.yml/badge.svg)](https://github.com/codeceptjs/CodeceptJS/actions/workflows/appiumV2_iOS.yml)

Web Helper:
[![Playwright Tests](https://github.com/codeceptjs/CodeceptJS/actions/workflows/playwright.yml/badge.svg)](https://github.com/codeceptjs/CodeceptJS/actions/workflows/playwright.yml)
[![Puppeteer Tests](https://github.com/codeceptjs/CodeceptJS/actions/workflows/puppeteer.yml/badge.svg)](https://github.com/codeceptjs/CodeceptJS/actions/workflows/puppeteer.yml)
[![WebDriver Tests](https://github.com/codeceptjs/CodeceptJS/actions/workflows/webdriver.yml/badge.svg)](https://github.com/codeceptjs/CodeceptJS/actions/workflows/webdriver.yml)
[![Appium Tests](https://github.com/codeceptjs/CodeceptJS/actions/workflows/appium.yml/badge.svg)](https://github.com/codeceptjs/CodeceptJS/actions/workflows/appium.yml)
[![TestCafe Tests](https://github.com/codeceptjs/CodeceptJS/actions/workflows/testcafe.yml/badge.svg)](https://github.com/codeceptjs/CodeceptJS/actions/workflows/testcafe.yml)

# CodeceptJS [![Made in Ukraine](https://img.shields.io/badge/made_in-ukraine-ffd700.svg?labelColor=0057b7)](https://stand-with-ukraine.pp.ua)
Expand Down
1 change: 1 addition & 0 deletions lib/helper/Appium.js
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ class Appium extends Webdriver {
this.axios = axios.create();

webdriverio = require('webdriverio');
console.log('The Appium core team does not maintain Appium 1.x anymore since the 1st of January 2022. Please migrating to Appium 2.x by adding appiumV2: true to your config.\nThis Appium 1.x support will be removed in next major release');
}

_validateConfig(config) {
Expand Down
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,10 @@
"test:unit": "mocha test/unit --recursive --timeout 10000",
"test:runner": "mocha test/runner --recursive --timeout 10000",
"test": "npm run test:unit && npm run test:runner",
"test:appium-quick": "mocha test/helper/Appium_test.js --grep 'quick'",
"test:appium-other": "mocha test/helper/Appium_test.js --grep 'second'",
"test:appium-quick": "mocha test/helper/AppiumV2_test.js --grep 'quick'",
"test:appium-other": "mocha test/helper/AppiumV2_test.js --grep 'second'",
"test:ios:appium-quick": "mocha test/helper/AppiumV2_ios_test.js --grep 'quick'",
"test:ios:appium-other": "mocha test/helper/AppiumV2_ios_test.js --grep 'second'",
"test-app:start": "php -S 127.0.0.1:8000 -t test/data/app",
"test-app:stop": "kill -9 $(lsof -t -i:8000)",
"test:unit:webbapi:playwright": "mocha test/helper/Playwright_test.js",
Expand Down
165 changes: 165 additions & 0 deletions test/helper/AppiumV2Web_test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,165 @@
const Appium = require('../../lib/helper/Appium');
global.codeceptjs = require('../../lib');

let I;
const site_url = 'http://davertmik.github.io';

describe('Appium Web', function () {
this.retries(4);
this.timeout(70000);

before(() => {
I = new Appium({
url: site_url,
appiumV2: true,
browser: 'chrome',
restart: false,
desiredCapabilities: {
'sauce:options': {
appiumVersion: '2.0.0',
},
recordVideo: 'false',
recordScreenshots: 'false',
platformName: 'Android',
platformVersion: '6.0',
deviceName: 'Android Emulator',
},
host: 'ondemand.saucelabs.com',
port: 80,
// port: 4723,
// host: 'localhost',
user: process.env.SAUCE_USERNAME,
key: process.env.SAUCE_ACCESS_KEY,
});
// I.isWeb = true;
I._init();
I._beforeSuite();
});

after(() => I._finishTest());

beforeEach(() => {
I.isWeb = true;
return I._before();
});

afterEach(() => I._after());

describe('current url : #seeInCurrentUrl, #seeCurrentUrlEquals, ...', () => {
it('should check for url fragment', async () => {
await I.amOnPage('/angular-demo-app/#/info');
await I.seeInCurrentUrl('/info');
await I.dontSeeInCurrentUrl('/result');
});

it('should check for equality', async () => {
await I.amOnPage('/angular-demo-app/#/info');
await I.seeCurrentUrlEquals('/angular-demo-app/#/info');
await I.dontSeeCurrentUrlEquals('/angular-demo-app/#/result');
});
});

describe('see text : #see', () => {
it('should check text on site', async () => {
await I.amOnPage('/angular-demo-app/');
await I.see('Description');
await I.dontSee('Create Event Today');
});

it('should check text inside element', async () => {
await I.amOnPage('/angular-demo-app/#/info');
await I.see('About', 'h1');
await I.see('Welcome to event app', { css: 'p.jumbotron' });
await I.see('Back to form', '//div/a');
});
});

describe('see element : #seeElement, #dontSeeElement', () => {
it('should check visible elements on page', async () => {
await I.amOnPage('/angular-demo-app/');
await I.seeElement('.btn.btn-primary');
await I.seeElement({ css: '.btn.btn-primary' });
await I.dontSeeElement({ css: '.btn.btn-secondary' });
});
});

describe('#click', () => {
it('should click by text', async () => {
await I.amOnPage('/angular-demo-app/');
await I.dontSeeInCurrentUrl('/info');
await I.click('Get more info!');
await I.seeInCurrentUrl('/info');
});

it('should click by css', async () => {
await I.amOnPage('/angular-demo-app/');
await I.click('.btn-primary');
await I.wait(2);
await I.seeInCurrentUrl('/result');
});

it('should click by non-optimal css', async () => {
await I.amOnPage('/angular-demo-app/');
await I.click('form a.btn');
await I.wait(2);
await I.seeInCurrentUrl('/result');
});

it('should click by xpath', async () => {
await I.amOnPage('/angular-demo-app/');
await I.click('//a[contains(., "more info")]');
await I.seeInCurrentUrl('/info');
});

it('should click on context', async () => {
await I.amOnPage('/angular-demo-app/');
await I.click('.btn-primary', 'form');
await I.wait(2);
await I.seeInCurrentUrl('/result');
});

it('should click link with inner span', async () => {
await I.amOnPage('/angular-demo-app/#/result');
await I.click('Go to info');
await I.seeInCurrentUrl('/info');
});

it('should click buttons as links', async () => {
await I.amOnPage('/angular-demo-app/');
await I.click('Options');
await I.seeInCurrentUrl('/options');
});
});

describe('#grabTextFrom, #grabValueFrom, #grabAttributeFrom', () => {
it('should grab text from page', async () => {
await I.amOnPage('/angular-demo-app/#/info');
const val = await I.grabTextFrom('p.jumbotron');
val.should.be.equal('Welcome to event app');
});

it('should grab value from field', async () => {
await I.amOnPage('/angular-demo-app/#/options');
const val = await I.grabValueFrom('#ssh');
val.should.be.equal('PUBLIC-SSH-KEY');
});

it('should grab attribute from element', async () => {
await I.amOnPage('/angular-demo-app/#/info');
const val = await I.grabAttributeFrom('a.btn', 'ng-href');
val.should.be.equal('#/');
});
});

describe('#within', () => {
afterEach(() => I._withinEnd());

it('should work using within operator', async () => {
await I.amOnPage('/angular-demo-app/#/options');
await I.see('Choose if you ok with terms');
await I._withinBegin({ css: 'div.results' });
await I.see('SSH Public Key: PUBLIC-SSH-KEY');
await I.dontSee('Options');
});
});
});
Loading