Closed JacquesN16 closed 2 years ago
The reason for this problem is because the Apple's XCTest test driver's framework is different from the test driver used for Android Virtual Device and it does not natively support W3C standards for TouchAction interface implementation. So some of commands that we can find on NighwatchJS official documentations may not work properly. For that reason, we can use the gestures set that goes with XCtest driver (the list of all the gestures here ). To apply the gesture to Nightwatch test, use browser.execute('mobile: gesture', {arguments})
Describe the bug
I have recently switched to Nightwatch v2.0 beta for a test on iOS Simulator Device. In my test, I used the method moveToElement() after an assert.visible(). The assertion has passed perfectly, but there is a problem when it executed the moveToElement() method to the same element.
Sample test
sampleTest.js
```js client .url(url) .assert.visible('.ScratchCard__Canvas') .execute('mobile: swipe', {direction: 'up', velocity: 5000}) .pause(2000) .click('#w-cta') .pause(TIMEOUT_LOADER) .assert.visible('.ScratchCard__Canvas') <= received a code : 200 .moveToElement('.ScratchCard__Canvas',100,100) <= received a code: 404 ? ```
appium.log
```txt [debug] [WD Proxy] Matched '/actions' to command name 'performActions' [debug] [WD Proxy] Proxying [POST /actions] to [POST http://127.0.0.1:8100/session/D6DEEC45-F6E4-4BAF-A868-3FE24729D61F/actions] with body: {"actions":[{"actions":[{"type":"po interMove","origin":{"ELEMENT":":wdc:1640875612655","element-6066-11e4-a52e-4f735466cecf":":wdc:1640875612655"},"duration":100,"x":100,"y":100}],"parameters":{"pointerType":"t ouch"},"type":"pointer","id":"default mouse"}]} [WD Proxy] Got response with status 404: {"value":{"error":"stale element reference","message":"The element identified by \":wdc:1640875612655\" is either not present or it ha s expired from the internal cache. Try to find it again","traceback":"(\n\t0 CoreFoundation 0x00007fff20422fba __exceptionPreprocess + 242\n\t1 libobj c.A.dylib 0x00007fff20193ff5 objc_exception_throw + 48\n\t2 WebDriverAgentLib 0x000000010e8681cc -[FBElementCache elementForUUID:resolv eForAdditionalAttributes:andMaxDepth:] + 668\n\t3 WebDriverAgentLib 0x000000010e867eff -[FBElementCache elementForUUID:] + 79\n\t4 WebDriverAgentLib 0x000000010e7e6389 -[FBW3CActionsSynthesizer preprocessedActionItemsWith:] + 1337\n\t5 WebDriverAgentLib 0x000000010e7e78e6 -[FBW3CActionsSyn thesizer eventPathsWithGestureAction:forActionId:error:] + 1334\n\t6 WebDriverAgentLib 0x000000010e7e8696 -[FBW3CActionsSynthesizer eventPathsWithActionDes cription:for... [debug] [W3C] Matched W3C error code 'stale element reference' to StaleElementReferenceError [debug] [W3C (1b0bacfe)] Encountered internal error running command: StaleElementReferenceError: The element identified by ":wdc:1640875612655" is either not present or it has expired from the internal cache. Try to find it again ```
Configuration
nightwatch.json
```js { live_output: false, globals_path: "nightwatch.globals.js", test_settings: { default: { launch_url: 'https://nightwatchjs.org', selenium_port: 4723, selenium_host: "127.0.0.1", silent: true, selenium_start_process: false, }, ios : { desiredCapabilities : { automationName: "XCUITest", browserName : "safari", platformName : "iOS", platformVersion : "14.5", deviceName : "iPhone 12 Pro Max", real_mobile : false, connectHardwareKeyboard: false } }, } } ```
Your Environment
nightwatch --version
npm --version
yarn --version
node --version
appium