Skip to content

Commit

Permalink
fix: deprecate appium 1.x
Browse files Browse the repository at this point in the history
  • Loading branch information
kobenguyent committed Nov 1, 2023
1 parent 2bc2a8b commit fb84f89
Show file tree
Hide file tree
Showing 5 changed files with 969 additions and 2 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/appium.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ on:
push:
branches:
- 3.x
- feat/appium-is-app-installed

-
env:
CI: true
# Force terminal colors. @see https://www.npmjs.com/package/colors
Expand Down
59 changes: 59 additions & 0 deletions .github/workflows/appiumV2.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: Appium V2 Tests

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: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:appium-other'
env: # Or as an environment variable
SAUCE_ACCESS_KEY: ${{ secrets.SAUCE_ACCESS_KEY }}
SAUCE_USERNAME: ${{ secrets.SAUCE_USERNAME }}
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
163 changes: 163 additions & 0 deletions test/helper/AppiumV2Web_test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,163 @@
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: {
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

0 comments on commit fb84f89

Please sign in to comment.