Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Damjan Smickovski authored and Damjan Smickovski committed Jun 27, 2023
0 parents commit bd701f5
Show file tree
Hide file tree
Showing 8 changed files with 2,384 additions and 0 deletions.
47 changes: 47 additions & 0 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: CI

on: [push]

jobs:
test:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Set up Node.js
uses: actions/setup-node@v2
with:
node-version: 16

- name: Install dependencies
run: yarn install

- name: Set up JDK 1.8
uses: actions/setup-java@v2
with:
distribution: 'adopt'
java-version: '8'

- name: Set up Android SDK
uses: android-actions/setup-android@v2

- name: Create and start emulator
run: |
echo "y" | sdkmanager "system-images;android-30;google_apis;x86"
echo "no" | avdmanager create avd --force --name Pixel_3a_API_30_x86 --package "system-images;android-30;google_apis;x86" --device "pixel_3a"
$ANDROID_HOME/emulator/emulator -avd Pixel_3a_API_30_x86 -no-snapshot -no-window -no-audio -gpu swiftshader_indirect &
adb wait-for-device shell 'while [[ -z $(getprop sys.boot_completed) ]]; do sleep 1; done; input keyevent 82'
- name: Install and start Appium
run: |
yarn global add appium@next
appium &
- name: Run tests
env:
LOG_LEVEL: debug
APPIUM_PORT: 4723
APPIUM_HOST: localhost
run: yarn test
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
node_modules
mochawesome-report
.env
19 changes: 19 additions & 0 deletions .mocharc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"require": [
"ts-node/register"
],
"extension": [
"ts"
],
"spec": "src/tests/**/*.ts",
"timeout": 50000,
"watch-files": [
"src/tests/**/*.ts"
],
"recursive": true,
"reporter": "mochawesome",
"reporterOptions": {
"reportFilename": "customReportFilename",
"quiet": true
}
}
36 changes: 36 additions & 0 deletions appium-conf.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import dotenv from 'dotenv';

dotenv.config();


const { APPIUM_HOST, APPIUM_PORT, LOG_LEVEL } = process.env;

if (!APPIUM_HOST) {
throw new Error("Missing APPIUM_HOST")
}

if (!APPIUM_PORT) {
throw new Error("Missing APPIUM_PORT")
}

const capabilitiesAndroid = {
platformName: 'Android',
'appium:automationName': 'UiAutomator2',
'appium:deviceName': 'Android',
'appium:appPackage': 'com.android.settings',
'appium:appActivity': '.Settings',
};

const capabilitiesIOS = {
// For demo purposes not implemented
};


export const getConfig = (platform: 'android' | 'ios') => {
return {
host: APPIUM_HOST,
port: parseInt(APPIUM_PORT),
logLevel: LOG_LEVEL || 'info',
capabilities: platform === 'android' ? capabilitiesAndroid : capabilitiesIOS,
}
}
24 changes: 24 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"name": "appium_test",
"version": "1.0.0",
"main": "index.js",
"license": "MIT",
"ext": "ts, js",
"scripts": {
"test": "mocha -r tsconfig-paths/register -r ts-node/register"
},
"devDependencies": {
"@types/node": "^20.3.2",
"ts-node": "^10.9.1",
"webdriverio": "^8.11.2"
},
"dependencies": {
"@types/mocha": "^10.0.1",
"dotenv": "^16.3.1",
"mocha": "^10.2.0",
"mochawesome": "^7.1.3",
"strip-ansi": "6.0.0",
"tsconfig-paths": "^4.2.0",
"typescript": "^5.1.3"
}
}
19 changes: 19 additions & 0 deletions src/tests/settingsTest.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@

const { remote } = require('webdriverio');
import { getConfig } from '../../appium-conf';

describe("Settings suite", async () => {
const config = getConfig('android');

it("should open settings", async () => {
const driver = await remote(config);
try {
const batteryItem = await driver.$('//*[@text="Battery"]');
await batteryItem.click();
} finally {
await driver.pause(1000);
await driver.deleteSession();
}
});

})
24 changes: 24 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"compilerOptions": {
"target": "ES2020",
"module": "CommonJS",
"esModuleInterop": true,
"resolveJsonModule": true,
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"outDir": "dist",
"baseUrl": "./src",
"paths": {
"@tests/*": [
"tests/*"
],
},
"strict": true
},
"include": [
"src/**/*",
],
"exclude": [
"node_modules"
]
}
Loading

0 comments on commit bd701f5

Please sign in to comment.