From ac7a23a57cc33ac9d5a3cfb720b7c2381618fccd Mon Sep 17 00:00:00 2001 From: Mikk Tendermann Date: Fri, 20 May 2022 17:57:08 +0300 Subject: [PATCH 1/2] use W3C standards when interfacing with appium. It may still be broken when interfacing Ios, because I have no idea what IOS platform name is --- lib/helper/WebDriver.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/helper/WebDriver.js b/lib/helper/WebDriver.js index 54cad7265..2becb0682 100644 --- a/lib/helper/WebDriver.js +++ b/lib/helper/WebDriver.js @@ -907,7 +907,7 @@ class WebDriver extends Helper { * {{ react }} */ async click(locator, context = null) { - const clickMethod = this.browser.isMobile ? 'touchClick' : 'elementClick'; + const clickMethod = this.browser.isMobile && this.browser.platformName !== 'android' ? 'touchClick' : 'elementClick'; const locateFn = prepareLocateFn.call(this, context); const res = await findClickable.call(this, locator, locateFn); @@ -1117,7 +1117,7 @@ class WebDriver extends Helper { * Appium: not tested */ async checkOption(field, context = null) { - const clickMethod = this.browser.isMobile ? 'touchClick' : 'elementClick'; + const clickMethod = this.browser.isMobile && this.browser.platformName !== 'android' ? 'touchClick' : 'elementClick'; const locateFn = prepareLocateFn.call(this, context); const res = await findCheckable.call(this, field, locateFn); @@ -1136,7 +1136,7 @@ class WebDriver extends Helper { * Appium: not tested */ async uncheckOption(field, context = null) { - const clickMethod = this.browser.isMobile ? 'touchClick' : 'elementClick'; + const clickMethod = this.browser.isMobile && this.browser.platformName !== 'android' ? 'touchClick' : 'elementClick'; const locateFn = prepareLocateFn.call(this, context); const res = await findCheckable.call(this, field, locateFn); @@ -1623,7 +1623,7 @@ class WebDriver extends Helper { assertElementExists(res); const elem = usingFirstElement(res); const elementId = getElementId(elem); - if (this.browser.isMobile) return this.browser.touchScroll(offsetX, offsetY, elementId); + if (this.browser.isMobile && this.browser.platformName !== 'android') return this.browser.touchScroll(offsetX, offsetY, elementId); const location = await elem.getLocation(); assertElementExists(location, 'Failed to receive', 'location'); /* eslint-disable prefer-arrow-callback */ @@ -1631,7 +1631,7 @@ class WebDriver extends Helper { /* eslint-enable */ } - if (this.browser.isMobile) return this.browser.touchScroll(locator, offsetX, offsetY); + if (this.browser.isMobile && this.browser.platformName !== 'android') return this.browser.touchScroll(locator, offsetX, offsetY); /* eslint-disable prefer-arrow-callback, comma-dangle */ return this.browser.execute(function (x, y) { return window.scrollTo(x, y); }, offsetX, offsetY); From 9dcf80c6fcb1c5e7e5faf0c9166b0cff8f37fb46 Mon Sep 17 00:00:00 2001 From: Mikk Tendermann Date: Fri, 20 May 2022 18:15:50 +0300 Subject: [PATCH 2/2] platform name is in capabilities --- lib/helper/WebDriver.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/helper/WebDriver.js b/lib/helper/WebDriver.js index 2becb0682..f7d919465 100644 --- a/lib/helper/WebDriver.js +++ b/lib/helper/WebDriver.js @@ -907,7 +907,7 @@ class WebDriver extends Helper { * {{ react }} */ async click(locator, context = null) { - const clickMethod = this.browser.isMobile && this.browser.platformName !== 'android' ? 'touchClick' : 'elementClick'; + const clickMethod = this.browser.isMobile && this.browser.capabilities.platformName !== 'android' ? 'touchClick' : 'elementClick'; const locateFn = prepareLocateFn.call(this, context); const res = await findClickable.call(this, locator, locateFn); @@ -1117,7 +1117,7 @@ class WebDriver extends Helper { * Appium: not tested */ async checkOption(field, context = null) { - const clickMethod = this.browser.isMobile && this.browser.platformName !== 'android' ? 'touchClick' : 'elementClick'; + const clickMethod = this.browser.isMobile && this.browser.capabilities.platformName !== 'android' ? 'touchClick' : 'elementClick'; const locateFn = prepareLocateFn.call(this, context); const res = await findCheckable.call(this, field, locateFn); @@ -1136,7 +1136,7 @@ class WebDriver extends Helper { * Appium: not tested */ async uncheckOption(field, context = null) { - const clickMethod = this.browser.isMobile && this.browser.platformName !== 'android' ? 'touchClick' : 'elementClick'; + const clickMethod = this.browser.isMobile && this.browser.capabilities.platformName !== 'android' ? 'touchClick' : 'elementClick'; const locateFn = prepareLocateFn.call(this, context); const res = await findCheckable.call(this, field, locateFn); @@ -1623,7 +1623,7 @@ class WebDriver extends Helper { assertElementExists(res); const elem = usingFirstElement(res); const elementId = getElementId(elem); - if (this.browser.isMobile && this.browser.platformName !== 'android') return this.browser.touchScroll(offsetX, offsetY, elementId); + if (this.browser.isMobile && this.browser.capabilities.platformName !== 'android') return this.browser.touchScroll(offsetX, offsetY, elementId); const location = await elem.getLocation(); assertElementExists(location, 'Failed to receive', 'location'); /* eslint-disable prefer-arrow-callback */ @@ -1631,7 +1631,7 @@ class WebDriver extends Helper { /* eslint-enable */ } - if (this.browser.isMobile && this.browser.platformName !== 'android') return this.browser.touchScroll(locator, offsetX, offsetY); + if (this.browser.isMobile && this.browser.capabilities.platformName !== 'android') return this.browser.touchScroll(locator, offsetX, offsetY); /* eslint-disable prefer-arrow-callback, comma-dangle */ return this.browser.execute(function (x, y) { return window.scrollTo(x, y); }, offsetX, offsetY);