admc / wd

A node.js client for webdriver/selenium 2.
Other
1.53k stars 402 forks source link

touchAction longPress does not seem to work on iOS simulator #564

Closed LayMuiToh closed 5 years ago

LayMuiToh commented 5 years ago

my code is as follow: let el = await driver.elementByAccessibilityId('HoldToTalk'); let action = new wd.TouchAction(); action.longPress(el); await action.perform();

When I run the test, I got this error: Invalid element or el field passed

 37 |    // let el = await driver.elementByAccessibilityId('HoldToTalk');
 38 |     let action = new wd.TouchAction();

39 | action.longPress(driver.elementByAccessibilityId('HoldToTalk')); | ^ 40 | await action.perform(); 41 | 42 | });

 at TouchAction.Object.<anonymous>.TouchAction.addGesture (node_modules/wd/lib/actions.js:21:11)
 at TouchAction.Object.<anonymous>.TouchAction.longPress (node_modules/wd/lib/actions.js:58:8)
 at Object.longPress (__tests__/login.e2e.js:39:12)
 at tryCatch (node_modules/regenerator-runtime/runtime.js:62:40)
 at Generator.invoke [as _invoke] (node_modules/regenerator-runtime/runtime.js:296:22)
 at Generator.prototype.(anonymous function) [as next] (node_modules/regenerator-runtime/runtime.js:114:21)
 at tryCatch (node_modules/regenerator-runtime/runtime.js:62:40)
 at invoke (node_modules/regenerator-runtime/runtime.js:152:20)
 at node_modules/regenerator-runtime/runtime.js:162:13
 at tryCallOne (node_modules/promise/lib/core.js:37:12)

Message Input

Jot something down

LayMuiToh commented 5 years ago

this is resolved by passing the driver as parameter to the TouchAction like this:let el = await driver.elementByAccessibilityId('HoldToTalk'); let action = new wd.TouchAction(driver); action.longPress({el}); await action.perform(); await action.release();

admc commented 5 years ago

Great, thanks for clarifying!