Webdriver 通过节点启动时,Appium记录的代码不工作

Webdriver 通过节点启动时,Appium记录的代码不工作,webdriver,appium,Webdriver,Appium,我已成功安装并运行appium desktop。我开始记录我的考试。记录器的输出代码如下所示: // Requires the webdriverio client library // (npm install webdriverio) // Then paste this into a .js file and run with Node: // node <file>.js const wdio = require('webdriverio'); const caps = {

我已成功安装并运行appium desktop。我开始记录我的考试。记录器的输出代码如下所示:

// Requires the webdriverio client library
// (npm install webdriverio)
// Then paste this into a .js file and run with Node:
// node <file>.js

const wdio = require('webdriverio');
const caps = {"platformName":"android","platformVersion":"8.0","deviceName":"Nexus_6_API_26_2","automationName":"UiAutomator2","app":"path/to/my/apk"};
const driver = wdio.remote({
  protocol: "http",
  host: "127.0.0.1",
  port: 4723,
  path: "/wd/hub",
  desiredCapabilities: caps
});

driver.init()
  .element("/some/xpath")
  .setValue("Hello World!")
  .end();
但是,此安装程序在使用节点this_test.js运行后将发现错误

错误:缺少必需的选项功能

因此,我将desiredCapabilities:caps更改为capabilities:caps,但在这之后,我得到了一个错误

TypeError:driver.init不是函数

我可以更改什么来修复此问题?我已经尝试用npm安装-g webdrivero和纱线添加webdrivero重新安装webdrivero


“我的服务器”运行在127.0.0.1:4723上,消息URL“/”未映射到有效资源(如果相关)

您使用的是MAC还是Windows计算机?MAC的地址会有所不同,比如0.0.0.0:4723/wd/hub

我正在使用Ubuntu。事实证明/wd/hub部分实际上是不相关的。我仍然在使用driver.init时遇到问题。init不是一个函数,任何函数都会抛出类似的错误。我认为驱动程序还没有定义,但我不知道如何在其余代码决定运行之前声明它。解决问题时请告诉我。