由于最新的 iOS 与 Appium 1.x 出现问题,Appium 团队不再支持它, Appium 2 工作正常 - 我需要使用 v2...
CodeceptJS 3.3.x 现在使用 Appium 1.x,由于 CodeceptJS Appium 帮助程序中默认使用“/wd/path”,我无法将其设置为使用 Appium 2。 开始测试时,CodeceptJS 失败并显示:
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
Appium 2 失败并显示:
[debug] [HTTP] No route found for /wd/hub/session
[HTTP] <-- POST /wd/hub/session 404 1 ms - 211
有没有办法将默认的“/wd/path”更改为“/”? 或者还有其他 Appium 2 的助手或者其他东西吗?
codecept.config.js 文件的部分内容:
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
},
},
============================================
我用 --base-path /wd/hub 启动 Appium (appium --base-path /wd/hub) 但现在出现另一个错误:
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
我尝试使用 appium: 前缀更新 codecept.conf.js 中的 capability,但要么我做错了,要么不起作用:
更新:
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: 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
错误#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
如果您使用 CLI 启动 Appium 服务器,您可以使用类似
appium -p 4726 --base-path /wd/hub
的内容,这将使其接受旧端点上的请求
更新: 在 Appium 2.0 中,Appium 服务器在功能方面将严格遵守 W3C WebDriver 规范。您可以在这里找到它们。您为 Appium 提供的任何其他内容都应具有
appium:
前缀(例如 appium:platformVersion
、appium:appPackage
等)
这很可能是 CodeceptJS 的 Appium 帮助程序的问题,需要更新以遵循 Appium 与 W3C WebDriver 规范更严格的兼容性。
更新需要支持以下前缀:
...
appium:platformName: 'iOS'
appium:automationName: 'xcuitest'
...
或
...
browserstack:platformName: 'Android'
saucelabs:automationName: 'uiautomator2'
...
目前,我们无法配置带前缀的变量。
据我所知,也无法联系 CodeceptJS 维护者来进行此更新。
在我这边,我在 Appium.js 文件中评论了这 3 行 现在它运行了
//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;
随着 CodeceptJS 3.5.0 的发布,这个问题已经解决了 添加
appiumV2: true
解释如下:https://codecept.io/wiki/Migration-to-Appium-v2---CodeceptJS.html