Skip to content

Commit

Permalink
check if browser is W3C instead of Android (codeceptjs#3414)
Browse files Browse the repository at this point in the history
  • Loading branch information
mikk150 authored and nlespiaucq committed Oct 27, 2022
1 parent 0e0a880 commit 1c2f5c8
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions lib/helper/WebDriver.js
Expand Up @@ -916,7 +916,7 @@ class WebDriver extends Helper {
* {{ react }}
*/
async click(locator, context = null) {
const clickMethod = this.browser.isMobile && this.browser.capabilities.platformName !== 'android' ? 'touchClick' : 'elementClick';
const clickMethod = this.browser.isMobile && !this.browser.isW3C ? 'touchClick' : 'elementClick';
const locateFn = prepareLocateFn.call(this, context);

const res = await findClickable.call(this, locator, locateFn);
Expand Down Expand Up @@ -1126,7 +1126,7 @@ class WebDriver extends Helper {
* Appium: not tested
*/
async checkOption(field, context = null) {
const clickMethod = this.browser.isMobile && this.browser.capabilities.platformName !== 'android' ? 'touchClick' : 'elementClick';
const clickMethod = this.browser.isMobile && !this.browser.isW3C ? 'touchClick' : 'elementClick';
const locateFn = prepareLocateFn.call(this, context);

const res = await findCheckable.call(this, field, locateFn);
Expand All @@ -1145,7 +1145,7 @@ class WebDriver extends Helper {
* Appium: not tested
*/
async uncheckOption(field, context = null) {
const clickMethod = this.browser.isMobile && this.browser.capabilities.platformName !== 'android' ? 'touchClick' : 'elementClick';
const clickMethod = this.browser.isMobile && !this.browser.isW3C ? 'touchClick' : 'elementClick';
const locateFn = prepareLocateFn.call(this, context);

const res = await findCheckable.call(this, field, locateFn);
Expand Down Expand Up @@ -1632,15 +1632,15 @@ class WebDriver extends Helper {
assertElementExists(res);
const elem = usingFirstElement(res);
const elementId = getElementId(elem);
if (this.browser.isMobile && this.browser.capabilities.platformName !== 'android') return this.browser.touchScroll(offsetX, offsetY, elementId);
if (this.browser.isMobile && !this.browser.isW3C) return this.browser.touchScroll(offsetX, offsetY, elementId);
const location = await elem.getLocation();
assertElementExists(location, 'Failed to receive', 'location');
/* eslint-disable prefer-arrow-callback */
return this.browser.execute(function (x, y) { return window.scrollTo(x, y); }, location.x + offsetX, location.y + offsetY);
/* eslint-enable */
}

if (this.browser.isMobile && this.browser.capabilities.platformName !== 'android') return this.browser.touchScroll(locator, offsetX, offsetY);
if (this.browser.isMobile && !this.browser.isW3C) 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);
Expand Down

0 comments on commit 1c2f5c8

Please sign in to comment.