如何使用 node.js 控制浏览器(ala Selenium)?
我听说过苏打 ,但似乎需要您注册,并且分钟数有限制(免费帐户/200 分钟)。
有谁知道是否有其他方法来控制浏览器,或者更具体地说,在网页上调用 JS?
I've heard of soda, but it seems like it requires you to signup and there's a limit on the # of minutes ( free acct / 200 minutes ).
Does anyone know if there's some alternative way to control a browser, or more specifically invoke JS on a web page?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
https://github.com/LearnBoost/soda/raw/master/examples /google.js
https://github.com/LearnBoost/soda/raw/master/examples/google.js
Zombie.js 可能适合你。它是无头的,看起来真的很酷。
Zombie.js might work for you. It is headless and seems really cool.
实际上,现在 JavaScript 的 Selenium 绑定可以与 Node.js 一起使用。
以下是一些入门的基本步骤:
拥有最新的 Chrome 驱动程序并将其放入您的路径中。
var webdriver = require('selenium-webdriver');
我通过一些屏幕截图介绍了如何执行此操作,以及如何使用 Mocha 作为测试驱动程序 我的博客文章在这里。
There are actually now Selenium bindings for JavaScript that work with Node.js.
Here are some basic steps to get started:
have the latest Chrome driver and put it in your path.
npm install selenium-webdriver
to get the module added to your project.var webdriver = require('selenium-webdriver');
I cover how to do this with some screenshots and how to use Mocha as a test driver in my blog post here.
这是一个围绕 selenium 的 webdriver 的 java API 的纯 Node.js 包装器:
https://npmjs.org/package/ webdriver-sync
这是一个示例:
将其保存在 .js 文件中并使用 Node 运行它。
该模块是一个纯粹的包装器,因此睡眠或同步调用之类的事情是完全可能的。这是模块的当前界面:
您可以在此处查看测试完整功能的集成测试:
https://github.com/jsdevel/webdriver-sync/blob/master/test/integrations/SmokeIT.js
Here's a pure node.js wrapper around the java API for selenium's webdriver:
https://npmjs.org/package/webdriver-sync
Here's an example:
Save that in a .js file and run it with node.
The module is a pure wrapper, so things like sleep or synchronous calls are entirely possible. Here's the current interface of the module:
You can see an integration test that tests the full capabilities here:
https://github.com/jsdevel/webdriver-sync/blob/master/test/integrations/SmokeIT.js
wd 是“适用于 webdriver/selenium 2 的 node.js javascript 客户端”
wd is "A node.js javascript client for webdriver/selenium 2"