Search code examples
iosselenium-webdrivernightwatch.jsxcode-ui-testing

Automation test with NightwatchJS on iOS simulator using XCUI


I try to do an automation UI test with NightWatchJS for a "click and drag" behavior and successfully executed it on Android Virtual Device. However, when I tried to launch the test on an IOS simulator (iPhone 12 Pro max, 14.5), with a command .mouseButtonDown() it showed an error for an "Unhandled endpoint"

The Appium log is shown as below:

[WD Proxy] Matched '/wd/hub/session/d033457a-e51c-4195-9d57-36976f50508a/buttondown' to command name 'buttonDown'
[WD Proxy] Proxying [POST /wd/hub/session/d033457a-e51c-4195-9d57-36976f50508a/buttondown] to [POST http://127.0.0.1:8100/session/680ECC16-09F1-472D-8D31-1C032771CC88/buttondown] with body: {"button":0}
[WD Proxy] Got response with status 404: 
{"value":
      {"error":"unknown command",
       "message":"Unhandled endpoint: /session/680ECC16-09F1-472D-8D31 1C032771CC88/buttondown 
-- http://127.0.0.1:8100/ with parameters {\n    wildcards = (\n  
      \"session/680ECC16-09F1-472D-8D31-1C032771CC88/buttondown\"\n    );\n}",
       "traceback":""},
       "sessionId":"680ECC16-09F1-472D-8D31-1C032771CC88"}
[debug] [W3C] Matched W3C error code 'unknown command' to UnknownCommandError
[HTTP] <-- POST /wd/hub/session/d033457a-e51c-4195-9d57-36976f50508a/buttondown 500 3 ms - 309

and here is the config for the test :

ios : {
    desiredCapabilities :{
        automationName: "XCUITest",
        browserName : "safari",
        platformName : "iOS",
        platformVersion : "14.5",
        deviceName : "iPhone 12 Pro Max",
        real_mobile : false,
        connectHardwareKeyboard: false
}

I may wonder if there's any way to work around this problem on iOS Simulator ?


Solution

  • 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})