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

时间:2019-01-22 13:05:15

标签: webdriver appium

我已经成功安装并运行了appium桌面。我开始记录测试。记录器的输出代码如下:

// 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();

但是使用node this_test.js运行此设置后会发现错误

Error: Required option "capabilities" is missing

因此,我将desiredCapabilities: caps更改为capabilities: caps,但是此后出现错误

TypeError: driver.init is not a function

该如何解决才能解决此问题?我尝试同时使用webdriverionpm install -g webdriverio重新安装yarn add webdriverio

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

1 个答案:

答案 0 :(得分:0)

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