【发布时间】:2019-08-24 01:40:17
【问题描述】:
我有一些由 Appium Recorder 生成的代码。当我尝试运行node test.js 时,它说“driver.init 不是函数”
我在同一个目录中运行了npm install webdriverio,并且那里有 node_modules 目录。
这里是test.js的内容:
// 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":"6.0.1","deviceName":"Nexus","automationName":"Appium","browserName":"Chrome"};
const driver = wdio.remote({
protocol: "http",
host: "localhost",
port: 4723,
path: "/wd/hub",
desiredCapabilities: caps
});
driver.init()
.element("com.android.chrome:id/url_bar")
.setValue("https://www.google.com/")
.end();
我希望代码能够运行,但上面写着 TypeError: driver.init is not a function
【问题讨论】:
-
试试
npm install webdriverio --save有没有其他代码用到了这个库? -
所以我尝试了
rm -rf node_modules然后npm install webdriverio --save然后node tests.js但我仍然得到driver.init is not a function。其他代码不应使用该库 -
下次你想刷新你的 node_modules 文件夹时使用
npm ci在 npm 5.8 版左右添加
标签: node.js appium webdriver-io appium-android