开发者问题收集

我收到错误 webdriver:由于未知命令,请求失败,状态为 404

2021-04-15
21532

显示的错误消息: `ERROR webdriver:由于未知命令,请求失败,状态为 404:找不到请求的资源,或者使用映射资源不支持的 HTTP 方法收到请求

ERROR webdriver: unknown command: The requested resource could not be found, or a request was received using an HTTP method that is not supported by the mapped resource

` wdio.conf.js 文件:

**let { join } = require('path'); exports.config = { port: 4723, // 默认 appium 端口 services: [ ['appium', { command : 'appium' }] ],

specs: [
    './test/specs/**/*.js'
],

maxInstances: 10,
capabilities: [{
    platformName:'Android',
    platformVersion:'9',
    deviceName:'Pixel',
    app:'D:/test/appium/test2/ApiDemos-debug.apk',   

bail: 0,   
baseUrl: 'http://localhost',    
waitforTimeout: 60000,    
connectionRetryTimeout: 120000,   
connectionRetryCount: 3, 

framework: 'mocha',

}**

package.json 文件: ** {

"name": "test2",

"version": "1.0.0",

"description": "",

"main": "index.js",

"scripts": {

"test": "./node_modules/.bin/wdio wdio.conf.js"

},

"keywords": [],

"author": "",

"license": "ISC",

"dependencies": {

"@wdio/cli": "^7.3.1",

"appium": "^1.20.2"

},

"devDependencies": {{

"@wdio/appium-service": "^7.4.2",

"@wdio/local-runner": "^7.3.1",

"@wdio/mocha-framework": "^7.3.1",

"@wdio/selenium-standalone-service": "^7.3.1",

"@wdio/spec-reporter": "^7.3.1",

"@wdio/sync": "^7.3.1",

"chromedriver": "^89.0.0",

"wdio-chromedriver-service": "^7.0.0"

}} **

3个回答

在命令行中运行此命令来启动 appium

appium --base-path /wd/hub

并确保 Appium 检查器中的“远程路径”是

/wd/hub
flame3
2021-10-25

在配置文件中添加路径:'/wd/hub/'。

Mahendra Kumar
2021-05-22

我刚刚试过。它有效。 您需要在基本 URL 上添加 /wd/hub baseUrl: 'http://localhost/wd/hub'

此外,您需要使用以下命令启动 appium 服务器

appium --base-path /wd/hub

steven zhang
2023-03-18