From bdbc17e5dbb9bd8039e4ea6df808590894184f52 Mon Sep 17 00:00:00 2001 From: Davert Date: Sat, 13 Apr 2019 22:57:00 +0300 Subject: [PATCH 1/8] Appium test fixes --- lib/helper/Appium.js | 9 +++++---- test/helper/Appium_test.js | 8 ++++---- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/lib/helper/Appium.js b/lib/helper/Appium.js index 74660a532..d6c9ccb23 100644 --- a/lib/helper/Appium.js +++ b/lib/helper/Appium.js @@ -985,10 +985,10 @@ class Appium extends Webdriver { * Perform a certain touch action on the screen such as swipeDown, swipeUp, swipeLeft, swipeRight. * * ```js - * I.swipeDown('swipeDown'); // perform swipe down on the screen - * I.swipeDown('swipeUp'); // perform swipe up on the screen - * I.swipeDown('swipeLeft'); // perform swipe left on the screen - * I.swipeDown('swipeRight'); // perform swipe right on the screen + * I.performTouchAction('swipeDown'); // perform swipe down on the screen + * I.performTouchAction('swipeUp'); // perform swipe up on the screen + * I.performTouchAction('swipeLeft'); // perform swipe left on the screen + * I.performTouchAction('swipeRight'); // perform swipe right on the screen * ``` * * @param action @@ -1026,6 +1026,7 @@ class Appium extends Webdriver { } /** + * * Perform a swipe left on an element. * * ```js diff --git a/test/helper/Appium_test.js b/test/helper/Appium_test.js index f219e0e3e..4f674486f 100644 --- a/test/helper/Appium_test.js +++ b/test/helper/Appium_test.js @@ -88,7 +88,7 @@ describe('Appium', function () { }, ); - it.only('should remove App and install it again', () => app.seeAppIsInstalled('io.selendroid.testapp') + it('should remove App and install it again', () => app.seeAppIsInstalled('io.selendroid.testapp') .then(() => app.removeApp('io.selendroid.testapp')) .then(() => app.seeAppIsNotInstalled('io.selendroid.testapp')) .then(() => app.installApp(apk_path)) @@ -220,7 +220,7 @@ describe('Appium', function () { assert.equal(val, '.WebViewActivity'); }); - it('should react on swipe action @second', function* () { + it('should react on swipe action', function* () { yield app.click("//android.widget.Button[@resource-id = 'io.selendroid.testapp:id/touchTest']"); yield app.waitForText( 'Gesture Type', 10, @@ -345,7 +345,7 @@ describe('Appium', function () { }); describe('#performTouchAction', () => { - it('should react on swipeUp action', function* () { + it('should react on swipeUp action @second', function* () { yield app.click("//android.widget.Button[@resource-id = 'io.selendroid.testapp:id/touchTest']"); yield app.waitForText( 'Gesture Type', 10, @@ -359,7 +359,7 @@ describe('Appium', function () { expect(vy.split(' ')[1]).to.be.below(1006); }); - it('should react on swipeDown action', function* () { + it('should react on swipeDown action @second', function* () { yield app.click("//android.widget.Button[@resource-id = 'io.selendroid.testapp:id/touchTest']"); yield app.waitForText( 'Gesture Type', 10, From 6622b53a9eb9a9eafc3dd93b1675f13a3f8a3149 Mon Sep 17 00:00:00 2001 From: Thanh Nguyen Date: Mon, 15 Apr 2019 11:15:14 +0200 Subject: [PATCH 2/8] debug failed appium tests --- lib/helper/Appium.js | 3 ++- test/helper/Appium_test.js | 1 - 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/helper/Appium.js b/lib/helper/Appium.js index d6c9ccb23..fa419d0cd 100644 --- a/lib/helper/Appium.js +++ b/lib/helper/Appium.js @@ -893,7 +893,8 @@ class Appium extends Webdriver { } async _swipeOnPercentage(from, to) { - SCREEN_SIZE = SCREEN_SIZE || await this.browser.getWindowRect(); + console.log(this.browser.isW3C); + SCREEN_SIZE = SCREEN_SIZE || this.browser.isW3C ? await this.browser.getWindowRect() : this.browser.getWindowSize(); const pressOptions = this._getDeviceScreenCoordinates(SCREEN_SIZE, from); const moveToScreenCoordinates = this._getDeviceScreenCoordinates(SCREEN_SIZE, to); await this.performSwipe( diff --git a/test/helper/Appium_test.js b/test/helper/Appium_test.js index 4f674486f..4eeb81540 100644 --- a/test/helper/Appium_test.js +++ b/test/helper/Appium_test.js @@ -354,7 +354,6 @@ describe('Appium', function () { yield app.performTouchAction('swipeUp'); const type = yield app.grabTextFrom("//android.widget.TextView[@resource-id = 'io.selendroid.testapp:id/gesture_type_text_view']"); const vy = yield app.grabTextFrom("//android.widget.TextView[@resource-id = 'io.selendroid.testapp:id/text_view4']"); - console.log(vy.split(' ')[1]); assert.equal(type, 'FLICK'); expect(vy.split(' ')[1]).to.be.below(1006); }); From 09a4afb256af75c7ca1ce1cfa41eb30a5c92ac29 Mon Sep 17 00:00:00 2001 From: Thanh Nguyen Date: Mon, 15 Apr 2019 13:25:36 +0200 Subject: [PATCH 3/8] fixed appium tests --- lib/helper/Appium.js | 3 +-- test/helper/Appium_test.js | 7 ++++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/helper/Appium.js b/lib/helper/Appium.js index fa419d0cd..f0541be4e 100644 --- a/lib/helper/Appium.js +++ b/lib/helper/Appium.js @@ -893,8 +893,7 @@ class Appium extends Webdriver { } async _swipeOnPercentage(from, to) { - console.log(this.browser.isW3C); - SCREEN_SIZE = SCREEN_SIZE || this.browser.isW3C ? await this.browser.getWindowRect() : this.browser.getWindowSize(); + SCREEN_SIZE = SCREEN_SIZE || !this.browser.isW3C ? await this.browser.getWindowRect() : await this.browser.getWindowSize(); const pressOptions = this._getDeviceScreenCoordinates(SCREEN_SIZE, from); const moveToScreenCoordinates = this._getDeviceScreenCoordinates(SCREEN_SIZE, to); await this.performSwipe( diff --git a/test/helper/Appium_test.js b/test/helper/Appium_test.js index 4eeb81540..a3b6bbbf1 100644 --- a/test/helper/Appium_test.js +++ b/test/helper/Appium_test.js @@ -260,7 +260,8 @@ describe('Appium', function () { 'Gesture Type', 10, "//android.widget.TextView[@resource-id = 'io.selendroid.testapp:id/gesture_type_text_view']", ); - yield app.swipeDown('#io.selendroid.testapp:id/LinearLayout1'); + // yield app.swipeDown('#io.selendroid.testapp:id/LinearLayout1'); + yield app.performTouchAction('swipeDown'); const type = yield app.grabTextFrom("//android.widget.TextView[@resource-id = 'io.selendroid.testapp:id/gesture_type_text_view']"); // const vy = yield app.grabTextFrom("//android.widget.TextView[@resource-id = 'io.selendroid.testapp:id/text_view4']"); assert.equal(type, 'FLICK'); @@ -424,10 +425,10 @@ describe('Appium', function () { }); describe('#pressKey', () => { - it('should be able to send special keys to element @second', function* () { + it.only('should be able to send special keys to element @second', function* () { yield app.click('~startUserRegistrationCD'); yield app.click('~email of the customer'); - yield app.pressKey('1'); + yield app.sendDeviceKeyEvent(1); yield app.hideDeviceKeyboard('pressKey', 'Done'); yield app.swipeTo( '//android.widget.Button', '//android.widget.ScrollView/android.widget.LinearLayout', 'up', 30, From 983ba87fcbb72a8b0caa7b40eb0ad6cf57c4020e Mon Sep 17 00:00:00 2001 From: Thanh Nguyen Date: Mon, 15 Apr 2019 13:29:39 +0200 Subject: [PATCH 4/8] fixed appium tests --- test/helper/Appium_test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/helper/Appium_test.js b/test/helper/Appium_test.js index a3b6bbbf1..f45a871f5 100644 --- a/test/helper/Appium_test.js +++ b/test/helper/Appium_test.js @@ -425,7 +425,7 @@ describe('Appium', function () { }); describe('#pressKey', () => { - it.only('should be able to send special keys to element @second', function* () { + it('should be able to send special keys to element @second', function* () { yield app.click('~startUserRegistrationCD'); yield app.click('~email of the customer'); yield app.sendDeviceKeyEvent(1); From 68183d6c9a39f3637f0fa488319e2c3d31c4a9b2 Mon Sep 17 00:00:00 2001 From: Thanh Nguyen Date: Mon, 15 Apr 2019 17:49:14 +0200 Subject: [PATCH 5/8] fixed appium tests --- lib/helper/Appium.js | 48 ++---------------------------- test/helper/Appium_test.js | 60 +++++++++++++++++++------------------- 2 files changed, 32 insertions(+), 76 deletions(-) diff --git a/lib/helper/Appium.js b/lib/helper/Appium.js index f0541be4e..09368414b 100644 --- a/lib/helper/Appium.js +++ b/lib/helper/Appium.js @@ -893,7 +893,7 @@ class Appium extends Webdriver { } async _swipeOnPercentage(from, to) { - SCREEN_SIZE = SCREEN_SIZE || !this.browser.isW3C ? await this.browser.getWindowRect() : await this.browser.getWindowSize(); + SCREEN_SIZE = SCREEN_SIZE || this.browser.isW3C ? await this.browser.windowHandleSize() : await this.browser.getWindowSize(); const pressOptions = this._getDeviceScreenCoordinates(SCREEN_SIZE, from); const moveToScreenCoordinates = this._getDeviceScreenCoordinates(SCREEN_SIZE, to); await this.performSwipe( @@ -923,7 +923,7 @@ class Appium extends Webdriver { onlyForApps.call(this); const res = await this.browser.$(parseLocator.call(this, locator)); // if (!res.length) throw new ElementNotFound(locator, 'was not found in UI'); - return this.browser.touchFlick(xoffset, yoffset, res.ELEMENT, speed); + return this.performSwipe(await res.getLocation(), { x: await res.getLocation().x + xoffset, y: await res.getLocation().y + yoffset }); } /** @@ -981,50 +981,6 @@ class Appium extends Webdriver { return this.swipe(locator, 0, yoffset, speed); } - /** - * Perform a certain touch action on the screen such as swipeDown, swipeUp, swipeLeft, swipeRight. - * - * ```js - * I.performTouchAction('swipeDown'); // perform swipe down on the screen - * I.performTouchAction('swipeUp'); // perform swipe up on the screen - * I.performTouchAction('swipeLeft'); // perform swipe left on the screen - * I.performTouchAction('swipeRight'); // perform swipe right on the screen - * ``` - * - * @param action - * @param percentage (optional), from 0 - 1, 1 by default - * - * Appium: support Android and iOS - */ - async performTouchAction(action, percentage = 1) { - switch (action) { - case 'swipeDown': - this._swipeOnPercentage( - this._calculateXY(SWIPE_DIRECTION.down.start, percentage), - this._calculateXY(SWIPE_DIRECTION.down.end, percentage), - ); - break; - case 'swipeUp': - this._swipeOnPercentage( - this._calculateXY(SWIPE_DIRECTION.up.start, percentage), - this._calculateXY(SWIPE_DIRECTION.up.end, percentage), - ); - break; - case 'swipeLeft': - this._swipeOnPercentage( - this._calculateXY(SWIPE_DIRECTION.left.start, percentage), - this._calculateXY(SWIPE_DIRECTION.left.end, percentage), - ); - break; - case 'swipeRight': - this._swipeOnPercentage( - this._calculateXY(SWIPE_DIRECTION.right.start, percentage), - this._calculateXY(SWIPE_DIRECTION.right.end, percentage), - ); - break; - } - } - /** * * Perform a swipe left on an element. diff --git a/test/helper/Appium_test.js b/test/helper/Appium_test.js index f45a871f5..b25a112e8 100644 --- a/test/helper/Appium_test.js +++ b/test/helper/Appium_test.js @@ -261,7 +261,10 @@ describe('Appium', function () { "//android.widget.TextView[@resource-id = 'io.selendroid.testapp:id/gesture_type_text_view']", ); // yield app.swipeDown('#io.selendroid.testapp:id/LinearLayout1'); - yield app.performTouchAction('swipeDown'); + yield app.swipeDown( + "//android.widget.LinearLayout[@resource-id = 'io.selendroid.testapp:id/LinearLayout1']", + 1200, 1000, + ); const type = yield app.grabTextFrom("//android.widget.TextView[@resource-id = 'io.selendroid.testapp:id/gesture_type_text_view']"); // const vy = yield app.grabTextFrom("//android.widget.TextView[@resource-id = 'io.selendroid.testapp:id/text_view4']"); assert.equal(type, 'FLICK'); @@ -346,59 +349,56 @@ describe('Appium', function () { }); describe('#performTouchAction', () => { - it('should react on swipeUp action @second', function* () { - yield app.click("//android.widget.Button[@resource-id = 'io.selendroid.testapp:id/touchTest']"); - yield app.waitForText( + it('should react on swipeUp action @second', async () => { + await app.click("//android.widget.Button[@resource-id = 'io.selendroid.testapp:id/touchTest']"); + await app.waitForText( 'Gesture Type', 10, "//android.widget.TextView[@resource-id = 'io.selendroid.testapp:id/gesture_type_text_view']", ); - yield app.performTouchAction('swipeUp'); - const type = yield app.grabTextFrom("//android.widget.TextView[@resource-id = 'io.selendroid.testapp:id/gesture_type_text_view']"); - const vy = yield app.grabTextFrom("//android.widget.TextView[@resource-id = 'io.selendroid.testapp:id/text_view4']"); + await app.swipeUp("//android.widget.TextView[@resource-id = 'io.selendroid.testapp:id/gesture_type_text_view']"); + const type = await app.grabTextFrom("//android.widget.TextView[@resource-id = 'io.selendroid.testapp:id/gesture_type_text_view']"); + const vy = await app.grabTextFrom("//android.widget.TextView[@resource-id = 'io.selendroid.testapp:id/text_view4']"); assert.equal(type, 'FLICK'); expect(vy.split(' ')[1]).to.be.below(1006); }); - it('should react on swipeDown action @second', function* () { - yield app.click("//android.widget.Button[@resource-id = 'io.selendroid.testapp:id/touchTest']"); - yield app.waitForText( + it('should react on swipeDown action @second', async () => { + await app.click("//android.widget.Button[@resource-id = 'io.selendroid.testapp:id/touchTest']"); + await app.waitForText( 'Gesture Type', 10, "//android.widget.TextView[@resource-id = 'io.selendroid.testapp:id/gesture_type_text_view']", ); - yield app.performTouchAction('swipeDown'); - const type = yield app.grabTextFrom("//android.widget.TextView[@resource-id = 'io.selendroid.testapp:id/gesture_type_text_view']"); - const vy = yield app.grabTextFrom("//android.widget.TextView[@resource-id = 'io.selendroid.testapp:id/text_view4']"); - console.log(vy.split(' ')[1]); + await app.swipeUp("//android.widget.TextView[@resource-id = 'io.selendroid.testapp:id/gesture_type_text_view']"); + const type = await app.grabTextFrom("//android.widget.TextView[@resource-id = 'io.selendroid.testapp:id/gesture_type_text_view']"); + const vy = await app.grabTextFrom("//android.widget.TextView[@resource-id = 'io.selendroid.testapp:id/text_view4']"); assert.equal(type, 'FLICK'); expect(vy.split(' ')[1]).to.be.above(178); }); - it('should react on swipeLeft action', function* () { - yield app.click("//android.widget.Button[@resource-id = 'io.selendroid.testapp:id/touchTest']"); - yield app.waitForText( + it('should react on swipeLeft action', async () => { + await app.click("//android.widget.Button[@resource-id = 'io.selendroid.testapp:id/touchTest']"); + await app.waitForText( 'Gesture Type', 10, "//android.widget.TextView[@resource-id = 'io.selendroid.testapp:id/gesture_type_text_view']", ); - yield app.performTouchAction('swipeLeft'); - const type = yield app.grabTextFrom("//android.widget.TextView[@resource-id = 'io.selendroid.testapp:id/gesture_type_text_view']"); - const vy = yield app.grabTextFrom("//android.widget.TextView[@resource-id = 'io.selendroid.testapp:id/text_view4']"); - console.log(vy.split(' ')[1]); + await app.swipeLeft("//android.widget.TextView[@resource-id = 'io.selendroid.testapp:id/gesture_type_text_view']"); + const type = await app.grabTextFrom("//android.widget.TextView[@resource-id = 'io.selendroid.testapp:id/gesture_type_text_view']"); + const vy = await app.grabTextFrom("//android.widget.TextView[@resource-id = 'io.selendroid.testapp:id/text_view4']"); assert.equal(type, 'FLICK'); expect(vy.split(' ')[1]).to.be.below(730); }); - it('should react on swipeRight action', function* () { - yield app.click("//android.widget.Button[@resource-id = 'io.selendroid.testapp:id/touchTest']"); - yield app.waitForText( + it('should react on swipeRight action', async () => { + await app.click("//android.widget.Button[@resource-id = 'io.selendroid.testapp:id/touchTest']"); + await app.waitForText( 'Gesture Type', 10, "//android.widget.TextView[@resource-id = 'io.selendroid.testapp:id/gesture_type_text_view']", ); - yield app.performTouchAction('swipeRight'); - const type = yield app.grabTextFrom("//android.widget.TextView[@resource-id = 'io.selendroid.testapp:id/gesture_type_text_view']"); - const vy = yield app.grabTextFrom("//android.widget.TextView[@resource-id = 'io.selendroid.testapp:id/text_view4']"); - console.log(vy.split(' ')[1]); + await app.swipeRight("//android.widget.TextView[@resource-id = 'io.selendroid.testapp:id/gesture_type_text_view']"); + const type = await app.grabTextFrom("//android.widget.TextView[@resource-id = 'io.selendroid.testapp:id/gesture_type_text_view']"); + const vy = await app.grabTextFrom("//android.widget.TextView[@resource-id = 'io.selendroid.testapp:id/text_view4']"); assert.equal(type, 'FLICK'); - expect(vy.split(' ')[1]).to.be.below(38); + expect(vy.split(' ')[1]).to.be.above(278); }); }); }); @@ -428,7 +428,7 @@ describe('Appium', function () { it('should be able to send special keys to element @second', function* () { yield app.click('~startUserRegistrationCD'); yield app.click('~email of the customer'); - yield app.sendDeviceKeyEvent(1); + yield app.pressKey('1'); yield app.hideDeviceKeyboard('pressKey', 'Done'); yield app.swipeTo( '//android.widget.Button', '//android.widget.ScrollView/android.widget.LinearLayout', 'up', 30, From 6f9469ef28298c8662b9af2e28d6d521cd6ad690 Mon Sep 17 00:00:00 2001 From: Thanh Nguyen Date: Wed, 17 Apr 2019 11:34:50 +0200 Subject: [PATCH 6/8] updated appium version --- test/helper/Appium_test.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/test/helper/Appium_test.js b/test/helper/Appium_test.js index b25a112e8..46774b3ac 100644 --- a/test/helper/Appium_test.js +++ b/test/helper/Appium_test.js @@ -20,7 +20,7 @@ describe('Appium', function () { app = new Appium({ app: apk_path, desiredCapabilities: { - appiumVersion: '1.6.4', + appiumVersion: '1.9.1', browserName: '', recordVideo: 'false', recordScreenshots: 'false', @@ -254,18 +254,18 @@ describe('Appium', function () { assert.ok(vy.match(/vy: \d\d000\.0 pps/), 'to be like \d\d000.0 pps'); }); - it('run simplified swipeDown @quick', function* () { - yield app.click("//android.widget.Button[@resource-id = 'io.selendroid.testapp:id/touchTest']"); - yield app.waitForText( + it('run simplified swipeDown @quick', async () => { + await app.click("//android.widget.Button[@resource-id = 'io.selendroid.testapp:id/touchTest']"); + await app.waitForText( 'Gesture Type', 10, "//android.widget.TextView[@resource-id = 'io.selendroid.testapp:id/gesture_type_text_view']", ); // yield app.swipeDown('#io.selendroid.testapp:id/LinearLayout1'); - yield app.swipeDown( + await app.swipeDown( "//android.widget.LinearLayout[@resource-id = 'io.selendroid.testapp:id/LinearLayout1']", 1200, 1000, ); - const type = yield app.grabTextFrom("//android.widget.TextView[@resource-id = 'io.selendroid.testapp:id/gesture_type_text_view']"); + const type = await app.grabTextFrom("//android.widget.TextView[@resource-id = 'io.selendroid.testapp:id/gesture_type_text_view']"); // const vy = yield app.grabTextFrom("//android.widget.TextView[@resource-id = 'io.selendroid.testapp:id/text_view4']"); assert.equal(type, 'FLICK'); }); From 22e21d76beda9771b2c6fca3e3f3ec2c641d91aa Mon Sep 17 00:00:00 2001 From: Thanh Nguyen Date: Wed, 17 Apr 2019 12:04:12 +0200 Subject: [PATCH 7/8] fixed failed appium tests - FINALLY --- docs/helpers/Appium.md | 35 ++++++++++------------ lib/helper/Appium.js | 60 +++++++++++--------------------------- test/helper/Appium_test.js | 6 ++-- 3 files changed, 35 insertions(+), 66 deletions(-) diff --git a/docs/helpers/Appium.md b/docs/helpers/Appium.md index 3398b9643..11fe6b14a 100644 --- a/docs/helpers/Appium.md +++ b/docs/helpers/Appium.md @@ -206,7 +206,7 @@ Field is located by name, label, CSS, or XPath. // by label I.fillField('Email', 'hello@world.com'); // by name -I.fillField('password', '123456'); +I.fillField('password', secret('123456')); // by CSS I.fillField('form#login input[name=username]', 'John'); // or by strict locator @@ -376,25 +376,7 @@ I.performswipe(100,200); #### Parameters - `from` -- `to` - -Appium: support Android and iOS - -### performTouchAction - -Perform a certain touch action on the screen such as swipeDown, swipeUp, swipeLeft, swipeRight. - -```js -I.swipeDown('swipeDown'); // perform swipe down on the screen -I.swipeDown('swipeUp'); // perform swipe up on the screen -I.swipeDown('swipeLeft'); // perform swipe left on the screen -I.swipeDown('swipeRight'); // perform swipe right on the screen -``` - -#### Parameters - -- `action` -- `percentage` (optional), from 0 - 1, 1 by defaultAppium: support Android and iOS +- `to` Appium: support Android and iOS ### pullFile @@ -704,6 +686,19 @@ I.sendDeviceKeyEvent(3); - `keyValue` Device specific key valueAppium: support only Android +### sendKey + +Send a sequence of key strokes to an element + +```js +I.sendKey('~email of the customer', '1');; +``` + +#### Parameters + +- `locator` element to send a sequence of key strokes +- `keys` a sequence of key strokes to send to an element + ### setImmediateValue Set immediate value in app. diff --git a/lib/helper/Appium.js b/lib/helper/Appium.js index 09368414b..9d6ff7d4a 100644 --- a/lib/helper/Appium.js +++ b/lib/helper/Appium.js @@ -15,25 +15,6 @@ const axios = requireg('axios'); const mobileRoot = '//*'; const webRoot = 'body'; -const SWIPE_DIRECTION = { - down: { - start: { x: 50, y: 15 }, - end: { x: 50, y: 85 }, - }, - left: { - start: { x: 95, y: 50 }, - end: { x: 5, y: 50 }, - }, - right: { - start: { x: 5, y: 50 }, - end: { x: 95, y: 50 }, - }, - up: { - start: { x: 50, y: 85 }, - end: { x: 50, y: 15 }, - }, -}; - /** * Appium helper extends [Webriver](http://codecept.io/helpers/WebDriver/) helper. @@ -826,6 +807,23 @@ class Appium extends Webdriver { return this.browser.pressKeyCode(keyValue); } + /** + * Send a sequence of key strokes to an element + * + * ```js + * I.sendKey('~email of the customer', '1');; + * ``` + * + * @param locator element to send a sequence of key strokes + * @param keys a sequence of key strokes to send to an element + * + */ + async sendKey(locator, keys) { + onlyForApps.call(this); + const res = await this.browser.$(parseLocator.call(this, locator)); + return res.addValue(keys); + } + /** * Open the notifications panel on the device. * @@ -878,30 +876,6 @@ class Appium extends Webdriver { return this.makeTouchAction(locator, 'tap'); } - _calculateXY({ x, y }, percentage) { - return { - x: x * percentage, - y: y * percentage, - }; - } - - _getDeviceScreenCoordinates(screenSize, coordinates) { - return { - x: Math.round(screenSize.width * (coordinates.x / 100)), - y: Math.round(screenSize.height * (coordinates.y / 100)), - }; - } - - async _swipeOnPercentage(from, to) { - SCREEN_SIZE = SCREEN_SIZE || this.browser.isW3C ? await this.browser.windowHandleSize() : await this.browser.getWindowSize(); - const pressOptions = this._getDeviceScreenCoordinates(SCREEN_SIZE, from); - const moveToScreenCoordinates = this._getDeviceScreenCoordinates(SCREEN_SIZE, to); - await this.performSwipe( - pressOptions, - moveToScreenCoordinates, - ); - } - /** * Perform a swipe on the screen or an element. * diff --git a/test/helper/Appium_test.js b/test/helper/Appium_test.js index 46774b3ac..a6b8d72f7 100644 --- a/test/helper/Appium_test.js +++ b/test/helper/Appium_test.js @@ -424,11 +424,11 @@ describe('Appium', function () { }); }); - describe('#pressKey', () => { - it('should be able to send special keys to element @second', function* () { + describe('#sendKey', () => { + it.only('should be able to send special keys to element @second', function* () { yield app.click('~startUserRegistrationCD'); yield app.click('~email of the customer'); - yield app.pressKey('1'); + yield app.sendKey('~email of the customer', '1'); yield app.hideDeviceKeyboard('pressKey', 'Done'); yield app.swipeTo( '//android.widget.Button', '//android.widget.ScrollView/android.widget.LinearLayout', 'up', 30, From 1855fde81f84a4d1b08d89e288ff64f0b3e02147 Mon Sep 17 00:00:00 2001 From: Thanh Nguyen Date: Wed, 17 Apr 2019 12:08:05 +0200 Subject: [PATCH 8/8] removed .only --- test/helper/Appium_test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/helper/Appium_test.js b/test/helper/Appium_test.js index a6b8d72f7..35e42d4b8 100644 --- a/test/helper/Appium_test.js +++ b/test/helper/Appium_test.js @@ -425,7 +425,7 @@ describe('Appium', function () { }); describe('#sendKey', () => { - it.only('should be able to send special keys to element @second', function* () { + it('should be able to send special keys to element @second', function* () { yield app.click('~startUserRegistrationCD'); yield app.click('~email of the customer'); yield app.sendKey('~email of the customer', '1');