ITGeine
Chapter 1.4 - Project Setup 본문
TAU 강의 - Appium 자바 스크립트 강의를 들으면서 메모하려고 한다.
해당 수업에서는 간단한 웹 테스트 프로젝트 생성 - 테스트 돌리는 시나리오까지 진행한다.
참고로 Chatper 1.1 ~ 1.3 으로는 사전에 필요한 환경 세팅 방법을 기술하고 있다.
> node.js, jdk, android sdk, android studio 등
1. mkdir 로 workspace 생성
2. npm init -y
{
"name": "testapp",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC"
}
y 옵션 사용 시 모든 설정이 default 값으로 설정됨 (프로젝트 이름, 버전)
package.json 파일 생성됨
3. npm i @wdio/cli
웹드라이버 테스트 러너 패키지 설치
> WebdriverIO testrunner command line interface.
ls 통해 확인해보면 아래 3개 파일 존재
node_modules
package-lock.json
package.json
4. ./node_modules/.bin/wdio config
=========================
WDIO Configuration Helper
=========================
? Where is your automation backend located? (Use arrow keys)
❯ On my local machine
In the cloud using Experitest
In the cloud using Sauce Labs
In the cloud using Browserstack or Testingbot or LambdaTest or a different service
I have my own Selenium cloud
wdio 환경설정
5. 생성된 wdio.config.js 파일 vscode 로 편집
exports.config = {
//
// ====================
// Runner Configuration
// ====================
runner : 'local',
port : 4723,
//
// ==================
// Specify Test Files
// ==================
// Define which test specs should run. The pattern is relative to the directory
// from which `wdio` was called.
//
// The specs are defined as an array of spec files (optionally using wildcards
// that will be expanded). The test for each spec file will be run in a separate
// worker process. In order to have a group of spec files run in the same worker
// process simply enclose them in an array within the specs array.
//
// If you are calling `wdio` from an NPM script (see https://docs.npmjs.com/cli/run-script),
// then the current working directory is where your `package.json` resides, so `wdio`
// will be called from there.
//
specs: [
'./test/specs/**/*.js'
],
runner configuration
port -> appium 사용 포트로 설정
specs -> 지정된 경로에 테스트 파일 위치해 있어야 함
capabilities: [{
// maxInstances can get overwritten per capability. So if you have an in-house Selenium
// grid with only 5 firefox instances available you can make sure that not more than
// 5 instances get started at a time.
maxInstances: 5,
//
browserName: 'chrome',
acceptInsecureCerts: true,
platformName: 'Android',
'appium:deviceName' : 'Pixel 4 API 30',
'appium:app' : '/Users/nick9/Documents/appium_js/ApiDemos-debug.apk'
// If outputDir is provided WebdriverIO can capture driver session logs
// it is possible to configure which logTypes to include/exclude.
// excludeDriverLogs: ['*'], // pass '*' to exclude all driver session logs
// excludeDriverLogs: ['bugreport', 'server'],
}],
capabilities ->
안드로이드 스튜디오에서 설치한 가상디바이스를 사용하도록 지정
테스트할 앱 경로 지정 (이번 테스트 스크립트에서는 웹만 사용하므로 무관하긴함)
* specs 폴더 내 테스트 스크립트
describe('My Login application', () => {
it('should login with valid credentials', async () => {
await browser.url(`https://the-internet.herokuapp.com/login`);
await $('#username').setValue('tomsmith');
await $('#password').setValue('SuperSecretPassword!');
await $('button[type="submit"]').click();
await expect($('#flash')).toBeExisting();
await expect($('#flash')).toHaveTextContaining(
'You logged into a secure area!');
});
});
6. ./node_modules/.bin/wdio wdio.conf.js
https://the-internet.herokuapp.com/login
The Internet
the-internet.herokuapp.com
페이지로 접근, id/password 입력 / 클릭 후 종료하는 시나리오로 정상 수행
spec 리포터에서 아래 결과 출력하고 종료
"spec" Reporter:
------------------------------------------------------------------
[chrome 101.0.4951.64 mac os x #0-0] Running: chrome (v101.0.4951.64) on mac os x
[chrome 101.0.4951.64 mac os x #0-0] Session ID: a3dae9261e76e810d126d89a1ecf7c9b
[chrome 101.0.4951.64 mac os x #0-0]
[chrome 101.0.4951.64 mac os x #0-0] » /test/specs/example.e2e.js
[chrome 101.0.4951.64 mac os x #0-0] My Login application
[chrome 101.0.4951.64 mac os x #0-0] ✓ should login with valid credentials
[chrome 101.0.4951.64 mac os x #0-0]
[chrome 101.0.4951.64 mac os x #0-0] 1 passing (3.6s)
'테스트 자동화 > Appium' 카테고리의 다른 글
appium 테스트 자동화 (0) | 2022.11.23 |
---|---|
Appium inspector - com.myactivity or com.myapp.com.myactivity never started (0) | 2022.05.27 |
Chapter 2.1: Finding Elements (0) | 2022.05.23 |
Chapter 1.5: Desired Capabilities (0) | 2022.05.23 |
No Chromedriver found that can automate Chrome '83.0.4103' (0) | 2022.05.23 |