【问题标题】:Appium recorded code not working when launched via nodesAppium 记录的代码在通过节点启动时不起作用
【发布时间】:2019-06-15 23:09:20
【问题描述】:

我已经成功安装并运行了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();

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

Error: Required option "capabilities" is missing

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

TypeError: driver.init is not a function

我可以改变什么来解决这个问题?我尝试使用npm install -g webdriverioyarn add webdriverio 重新安装webdriverio

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

【问题讨论】:

    标签: webdriver appium


    【解决方案1】:

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

    【讨论】:

    • 我正在使用 Ubuntu。原来/wd/hub 部分实际上是不相关的。我仍然遇到driver.init is not a function 的问题,任何函数都会抛出类似的错误。我认为driver 尚未定义,但我不知道如何在其余代码决定运行之前声明它。
    • 有趣。解决问题后告诉我。
    猜你喜欢
    • 1970-01-01
    • 2018-02-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-08-07
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多