Skip to content

Commit 017eec4

Browse files
fix(webdriver): click iOS elements with the W3C elementClick command (#5757)
click, checkOption and uncheckOption called the JSON Wire touchClick command on non-Android mobile sessions. webdriverio 9 deprecates it and webdriverio 10 removes it. elementClick is the W3C command the helper already uses on Android and desktop, and Appium XCUITest supports it.
1 parent a16a884 commit 017eec4

1 file changed

Lines changed: 3 additions & 6 deletions

File tree

‎lib/helper/WebDriver.js‎

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1079,7 +1079,6 @@ class WebDriver extends Helper {
10791079
*
10801080
*/
10811081
async click(locator, context = null) {
1082-
const clickMethod = this.browser.isMobile && this.browser.capabilities.platformName !== 'android' ? 'touchClick' : 'elementClick'
10831082
const locateFn = prepareLocateFn.call(this, context)
10841083

10851084
const res = await findClickable.call(this, locator, locateFn)
@@ -1090,7 +1089,7 @@ class WebDriver extends Helper {
10901089
}
10911090
const elem = selectElement(res, locator, this)
10921091
highlightActiveElement.call(this, elem)
1093-
return this.browser[clickMethod](getElementId(elem))
1092+
return this.browser.elementClick(getElementId(elem))
10941093
}
10951094

10961095
/**
@@ -1390,7 +1389,6 @@ class WebDriver extends Helper {
13901389
* {{> checkOption }}
13911390
*/
13921391
async checkOption(field, context = null) {
1393-
const clickMethod = this.browser.isMobile && this.browser.capabilities.platformName !== 'android' ? 'touchClick' : 'elementClick'
13941392
const locateFn = prepareLocateFn.call(this, context)
13951393

13961394
const res = await findCheckable.call(this, field, locateFn)
@@ -1403,15 +1401,14 @@ class WebDriver extends Helper {
14031401
const isSelected = await isElementChecked(this.browser, elementId)
14041402

14051403
if (isSelected) return Promise.resolve(true)
1406-
return this.browser[clickMethod](elementId)
1404+
return this.browser.elementClick(elementId)
14071405
}
14081406

14091407
/**
14101408
* Appium: not tested
14111409
* {{> uncheckOption }}
14121410
*/
14131411
async uncheckOption(field, context = null) {
1414-
const clickMethod = this.browser.isMobile && this.browser.capabilities.platformName !== 'android' ? 'touchClick' : 'elementClick'
14151412
const locateFn = prepareLocateFn.call(this, context)
14161413

14171414
const res = await findCheckable.call(this, field, locateFn)
@@ -1424,7 +1421,7 @@ class WebDriver extends Helper {
14241421
const isSelected = await isElementChecked(this.browser, elementId)
14251422

14261423
if (!isSelected) return Promise.resolve(true)
1427-
return this.browser[clickMethod](elementId)
1424+
return this.browser.elementClick(elementId)
14281425
}
14291426

14301427
/**

0 commit comments

Comments
 (0)