使用WebdriverJS
2020-12-13 06:06
标签:des blog class c code java 先用node安装 下载selenium-standalone server并运行 创建test_webdriver.js 用node执行 报错:the path to the driver executable must be set by the
webdriver.chrome.driver 解决:下载chromedriver https://code.google.com/p/selenium/wiki/ChromeDriver 在js文件中加入代码: 重新运行,报错: can‘t find module ‘system‘ 修改webdriver server的运行命令: 删掉js中加入的代码,运行成功 使用WebdriverJS,搜素材,soscw.com 使用WebdriverJS 标签:des blog class c code java 原文地址:http://www.cnblogs.com/fruityworld/p/3740465.html
npm install webdriverjs
java -jar path/to/your/selenium-server-standalone-2.39.0.jar
var
webdriverjs = require(
‘webdriverjs‘
);
var
options = { desiredCapabilities: { browserName:
‘chrome‘
} };
webdriverjs
.remote(options)
.init()
.url(
‘http://www.google.com‘
)
.title(
function
(err, res) {
console.log(
‘Title was: ‘
+ res.value);
})
.end();
node test_webdriver.js
var
System = require(
‘system‘
);
System.setProperty(
"webdriver.chrome.driver"
,
"C:\Program Files (x86)\Google\Chrome\Application"
);
java -jar selenium-server-standalone-2.35.0.jar -Dwebdriver.chrome.driver=
"D:\dev\chromedriver.exe"