简体   繁体   English

如何在JavaScript语言绑定中使用RemoteWebDriver? (在Node.js上运行)

[英]How do you use RemoteWebDriver in the javascript language bindings? (Running on Node.js)

I am trying to use the javascript language bindings to connect to a RemoteWebDriver, but I am having difficulty getting it to work, and the API documentation does not have any examples for RemoteWebDriver. 我正在尝试使用javascript语言绑定来连接到RemoteWebDriver,但是我很难使其正常工作,而且API文档中没有RemoteWebDriver的任何示例。 I've seen a few examples around of something like this supposedly working: 我已经看到了一些类似的示例,这些示例据说可以正常工作:

//Javascript example - not working
const webDriver = new Builder()
    .usingServer(url)
    .withCapabilities(/*don't know what to put here /*)
    .build();

I cannot figure which capabilities are needed. 我无法确定需要哪些功能。 A further complication is the remote webdriver I'm connecting to is a home rolled implementation of the protocol. 进一步的麻烦是,我连接的远程Webdriver是协议的本地实现。 As a test, I got the java version of RemoteWebDriver to work: 作为测试,我让RemoteWebDriver的Java版本可以工作:

//Java example - working
Capabilities capabilities = new DesiredCapabilities();
RemoteWebDriver driver;
driver = new RemoteWebDriver (url, capabilities);

I have a strong suspicion that the capabilities I am using in the javascript example are not sufficient, but I cannot figure out what the builder interface is expecting. 我非常怀疑我在javascript示例中使用的功能还不够,但是我无法弄清楚生成器界面的期望。 The default capabilities seem to work in the java version, but what are those? 默认功能似乎可以在Java版本中使用,但是这些功能是什么?

Any help will be greatly appreciated. 任何帮助将不胜感激。

If you are using JS bindings, set the below environment variables as mentioned here 如果您使用的是JS绑定,请按照此处所述设置以下环境变量

SELENIUM_BROWSER=chrome:36:LINUX \
 SELENIUM_REMOTE_URL=http://www.example.com:4444/wd/hub \

then you can just do 那你就可以做

var driver = new webdriver.Builder()
     .forBrowser('chrome')
     .build();

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用 Node.js web 服务器的超链接? - How do you use hyperlinks with a Node.js web server? 你怎么得到运行Node.js脚本的cron作业从.env文件中读取变量? - How do you get cron job running Node.js script to read variables from .env file? 如何确保浏览器和node.js的JavaScript库兼容 - How do you ensure compatibility JavaScript libraries for the browser and for node.js 在Javascript中(使用node.js时),您如何知道/定义变量的范围? - In Javascript (when using node.js), how do you know/define the scope of variables? 如何使用node.js和bash脚本运行javascript文件? - How do you run a javascript file using node.js and bash script? 在JavaScript / Node.js中运行.map时,如何跳过回调? - How do I skip a callback when running .map in JavaScript/Node.js? 您如何在客户端使用Node.js变量? - How do you use a Node.js variable on the client-side? Node.js module.exports 的用途是什么,你如何使用它? - What is the purpose of Node.js module.exports and how do you use it? 你如何在不使用 node.js、express 或构建工具的情况下使用 Threejs? - how do you use threejs WITHOUT using node.js, express, or a build tool? 如何在 node.js 中创建自定义异步函数? - How do you create custom asynchronous functions in node.js?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM