1

Because latest iOS is making problems with Appium 1.x, Appium team is no longer supporting it, and Appium 2 is working ok - I need to use v2...

CodeceptJS 3.3.x is using Appium 1.x now and because of the '/wd/path' used by default in CodeceptJS Appium helper, I can't set it to use Appium 2. When starting a test, CodeceptJS fails with:

Error: Failed to create session.
The requested resource could not be found, or a request was received using an HTTP method that is not supported by the mapped resource

Please make sure Selenium Server is running and accessible
Error: Can't connect to WebDriver.
Error: Failed to create session.
The requested resource could not be found, or a request was received using an HTTP method that is not supported by the mapped resource

Please make sure Selenium Server is running and accessible

And Appium 2 fails with:

[debug] [HTTP] No route found for /wd/hub/session
[HTTP] <-- POST /wd/hub/session 404 1 ms - 211

Is there a way to change the default '/wd/path' to just '/' ? Or is there another helper or something for Appium 2?

Part of the codecept.config.js file:

        Appium: {
            host: process.env.CLOUD_HOST || 'localhost',
            port: parseInt(process.env.CLOUD_PORT) || 4723,
            app: (PLATFORM_NAME === 'iOS') ? APP_PATH_IOS || 'com.mobile.beta' : APP_PATH_ANDROID,
            desiredCapabilities: {
                platformName: process.env.PLATFORM_NAME || 'iOS',
                platformVersion: process.env.PLATFORM_VERSION || '16.0',
                automationName: process.env.AUTOMATION_NAME || 'xcuitest',
                deviceName: process.env.DEVICE_NAME || 'iPhone Xs',
                appPackage: process.env.APP_PACKAGE,
                appActivity: process.env.APP_ACTIVITY,
                xcodeOrgId: process.env.XCODE_ORG_ID,
                // udid: process.env.UDID, // used only for real iOS device

            },
        },

=========================================

  • UPDATE:

I started Appium with --base-path /wd/hub (appium --base-path /wd/hub) but now another error appears:

Error: Can't connect to WebDriver.
Error: Failed to create session.
All non-standard capabilities should have a vendor prefix. The following capabilities did not have one: platformVersion,automationName,deviceName,appPackage,appActivity,xcodeOrgId,app

Please make sure Selenium Server is running and accessible

I tried updating the capabilities in codecept.conf.js with appium: prefix, but either I do it wrong or it doesn't work:

The Update:

        Appium: {
            host: process.env.CLOUD_HOST || 'localhost',
            port: parseInt(process.env.CLOUD_PORT) || 4723,
            app: (PLATFORM_NAME === 'iOS') ? APP_PATH_IOS || 'com.mobile.beta' : APP_PATH_ANDROID,
            desiredCapabilities: {
                'appium:platformName': process.env.PLATFORM_NAME || 'iOS',
                'appium:platformVersion': process.env.PLATFORM_VERSION || '16.0',
                'appium:automationName': process.env.AUTOMATION_NAME || 'xcuitest',
                'appium:deviceName': process.env.DEVICE_NAME || 'iPhone Xs',
                'appium:appPackage': process.env.APP_PACKAGE, // not needed for iOS
                'appium:appActivity': process.env.APP_ACTIVITY, // not needed for iOS
                'xcodeOrgId': process.env.XCODE_ORG_ID, // not needed for Android
                udid: process.env.UDID, // used only for real iOS device testing
            },
        },

Error:

Error: Can't connect to WebDriver.
Error: Invalid or unsupported WebDriver capabilities found ("platformVersion", "deviceName", "appPackage", "appActivity", "xcodeOrgId", "app", "tunnelIdentifier"). Ensure to only use valid W3C WebDriver capabilities (see https://w3c.github.io/webdriver/#capabilities).If you run your tests on a remote vendor, like Sauce Labs or BrowserStack, make sure that you put them into vendor specific capabilities, e.g. "sauce:options" or "bstack:options". Please reach out to to your vendor support team if you have further questions.

Please make sure Selenium Server is running and accessible

Error#2:

Error: Can't connect to WebDriver.
Error: Invalid or unsupported WebDriver capabilities found ("deviceName", "app", "tunnelIdentifier"). Ensure to only use valid W3C WebDriver capabilities (see https://w3c.github.io/webdriver/#capabilities).If you run your tests on a remote vendor, like Sauce Labs or BrowserStack, make sure that you put them into vendor specific capabilities, e.g. "sauce:options" or "bstack:options". Please reach out to to your vendor support team if you have further questions.

Please make sure Selenium Server is running and accessible

3 Answers3

0

If you are starting Appium server using the CLI you can use something like appium -p 4726 --base-path /wd/hub which will make it accept requests on the old endpoint

Update: With Appium 2.0, the Appium server will enforce strict compability with the W3C WebDriver specification when it comes to Capabilities. They can be found here. Anything else that you provide for Appium should have the appium: prefix (like appium:platformVersion, appium:appPackage and so on)

drunkencheetah
  • 354
  • 1
  • 8
  • This solved half of the the problem... Now a new error appeared: ` Error: Can't connect to WebDriver. Error: Failed to create session. All non-standard capabilities should have a vendor prefix. The following capabilities did not have one: **platformVersion,automationName,deviceName,appPackage,appActivity,xcodeOrgId,app** Please make sure Selenium Server is running and accessible ` – Dimitar Hristovski Oct 27 '22 at 13:19
  • I tried updating the capabilities in codecept.conf.js with appium: prefix, but either I do it wrong or it doesn't work: The Update: _'appium:automationName': process.env.AUTOMATION_NAME,_ The Error: _Error: Can't connect to WebDriver. Error: Invalid or unsupported WebDriver capabilities found ("platformVersion", "deviceName", "appPackage", "appActivity", "xcodeOrgId", "app", "tunnelIdentifier")._ – Dimitar Hristovski Oct 27 '22 at 13:50
  • I updated the answer with more info on the capabilities – drunkencheetah Oct 27 '22 at 14:02
  • I know, I updated them, and posted the new error in the **UPDATE:** section. Looks like CodeceptJS's Appium helper doesn't support the strings with prefix: 'appium:automationName': process.env.AUTOMATION_NAME when I updated them like this, appium (console) didn't even noticed the coonection ... – Dimitar Hristovski Oct 27 '22 at 15:46
  • You have updated only `automationName`. If you look closely it is listed in your first error and it is no longer listed in your second error. You also need to update `"platformVersion", "deviceName", "appPackage", "appActivity", "xcodeOrgId", "app", "tunnelIdentifier"` to use the prefix – drunkencheetah Oct 28 '22 at 06:00
  • I changed them all, I just posted one as an example – Dimitar Hristovski Oct 28 '22 at 10:13
  • The thing with the error is that it's for Webdriver and it says: **Error: Can't connect to WebDriver. Error: Invalid or unsupported WebDriver capabilities found** – Dimitar Hristovski Oct 28 '22 at 10:19
  • Yes, it is with WebDriver because you keep providing it incompatible capabilities. This looks like incompatibility of CodeceptJS with Appium 2.0. You can move `app` inside `desiredCapabilities` but you will keep getting an error due to `tunnelIdentifier` because if you are not setting it, then it is being hardcoded somewhere in CodeceptJS code – drunkencheetah Oct 28 '22 at 11:22
  • If I move app to desiredCapabilities (with or without 'appium:'), it throws this error: **Could not load helper Appium from module './helper/Appium': Appium requires either platform and app or a browser to be set. Check your codeceptjs config file to ensure these are set properly { "helpers": { "Appium": { "app": "/path/to/app/package" "platform": "MOBILE_OS", } } }** – Dimitar Hristovski Oct 28 '22 at 12:27
  • You will probably have to raise an issue with CodeceptJS maintainers to ask for support of Appium 2 or at least some pointers how to change the code to get it to work(if at all possible atm) – drunkencheetah Oct 29 '22 at 07:11
0

This is most probably a problem with the CodeceptJS's Appium helper and needs to be updated to follow the Appium's more strict compability with the W3C WebDriver specification.

The update needs a support for prefixes like:

...
appium:platformName: 'iOS'
appium:automationName: 'xcuitest'
...

or

...
browserstack:platformName: 'Android'
saucelabs:automationName: 'uiautomator2'
...

for now, we can't configure variables with prefixes.

There's also no way I know of, to contact the CodeceptJS maintainers for making this update.

0

On my side I commented these 3 lines in the Appium.js file and now it runs

//config.capabilities.deviceName = config.device || config.capabilities.deviceName;
config.capabilities.browserName = config.browser || config.capabilities.browserName;
//config.capabilities.app = config.app || config.capabilities.app;
config.capabilities.platformName = config.platform || config.capabilities.platformName;
//config.capabilities.tunnelIdentifier = config.tunnelIdentifier || config.capabilities.tunnelIdentifier;
config.waitForTimeoutInSeconds = config.waitForTimeout / 1000;
desertnaut
  • 57,590
  • 26
  • 140
  • 166
  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Jul 01 '23 at 04:47