使用Appium&;WebdriverIO:&Quot;未找到/Session&Quot;的移动应用程序测试 [英] Testing Mobile App with Appium & WebdriverIO: "No route found for /session"
本文介绍了使用Appium&;WebdriverIO:&Quot;未找到/Session&Quot;的移动应用程序测试的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我要设置Android和iOS平台移动应用程序的自动测试流程(Reaction Native)。为此,我使用Appium和WebdriverIO。例如,我使用现有的appium-boilerplate代码库和现成的application来运行测试。我在Android模拟器中运行该应用程序。基本设置如下所示。
1.应用
2.WebdriverIO
wdio.shared.conf.js
exports.config = {
// ====================
// Runner and framework
// Configuration
// ====================
runner: 'local',
framework: 'jasmine',
jasmineNodeOpts: {
// Updated the timeout to 30 seconds due to possible longer appium calls
// When using XPATH
defaultTimeoutInterval: 90000,
helpers: [require.resolve('@babel/register')],
},
sync: true,
logLevel: 'silent',
deprecationWarnings: true,
bail: 0,
baseUrl: 'http://the-internet.herokuapp.com',
waitforTimeout: 10000,
connectionRetryTimeout: 90000,
connectionRetryCount: 3,
reporters: ['spec'],
// ====================
// Appium Configuration
// ====================
services: [
[
'appium',
{
// For options see
// https://github.com/webdriverio/webdriverio/tree/master/packages/wdio-appium-service
args: {
// Auto download ChromeDriver
relaxedSecurity: true,
// chromedriverAutodownload: true,
// For more arguments see
// https://github.com/webdriverio/webdriverio/tree/master/packages/wdio-appium-service
},
command: 'appium',
},
],
],
port: 4723,
};
wdio.android.app.conf.js。
const { join } = require('path');
const { config } = require('./wdio.shared.conf');
// ============
// Specs
// ============
config.specs = [
'./tests/specs/**/app*.spec.js',
];
// ============
// Capabilities
// ============
// For all capabilities please check
// http://appium.io/docs/en/writing-running-appium/caps/#general-capabilities
config.capabilities = [
{
// The defaults you need to have in your config
platformName: 'Android',
maxInstances: 1,
// For W3C the appium capabilities need to have an extension prefix
// http://appium.io/docs/en/writing-running-appium/caps/
// This is `appium:` for all Appium Capabilities which can be found here
'appium:udid': 'emulator-5554',
'appium:deviceName': 'Android SDK build for x86_64',
'appium:platformVersion': '10.0',
'appium:orientation': 'PORTRAIT',
// `automationName` will be mandatory, see
// https://github.com/appium/appium/releases/tag/v1.13.0
'appium:automationName': 'Appium',
// The path to the app
'appium:app': join(process.cwd(), './apps/Android-NativeDemoApp-0.2.1.apk'),
// Read the reset strategies very well, they differ per platform, see
// http://appium.io/docs/en/writing-running-appium/other/reset-strategies/
'appium:noReset': true,
'appium:newCommandTimeout': 240,
},
];
exports.config = config;
3.步骤
首先打开Android模拟器并启动Appium服务器:
然后,我使用该命令运行测试npm run android.app
。之后,测试用例在后台执行,但仿真器中不发生任何操作,在终端中我看到消息[HTTP] No route found for /session
我的问题是:要修复此问题,需要注意什么?因为我不知道要看什么,也不知道如何正确设置配置。谢谢!
推荐答案
我们能够通过覆盖wdio.conf.js:
中的path
变量来解决此问题
...
path: '/wd/hub',
port: 4723,
services: ['appium'],
...
在没有定义路径的情况下,它显然默认为/session
,如您所见,失败的路径为404。
这篇关于使用Appium&;WebdriverIO:&Quot;未找到/Session&Quot;的移动应用程序测试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文