简体   繁体   中英

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. 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. As a test, I got the java version of RemoteWebDriver to work:

//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. The default capabilities seem to work in the java version, but what are those?

Any help will be greatly appreciated.

If you are using JS bindings, set the below environment variables as mentioned here

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();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM