Selenium grid Using Javascript and Node - Basics?

648 views
Skip to first unread message

Vijay Bhargav

unread,
Aug 3, 2015, 1:23:50 PM8/3/15
to Selenium Users
Hi Experts,

I am very much new to Selenium using javascript. I need to set up a grid and execute the test in multiple browsers. as a start, I am able to setup Hub and Node. I am trying to write sample script to invoke a browser on remote machine but i am not able to understand how things work in selenium with Js.

What is java RemoteServer equivalent in javascript and how to use it. 

here is my code.

var webdriver = require('selenium-webdriver');
var driver = new webdriver.Builder()
            .forBrowser('firefox')
            .usingServer('Localhost:5820')
            .withCapabilities(webdriver.Capabilities.firefox())
            .build();
driver.get('http://www.google.com');
driver.findElement(webdriver.By.name('q')).sendKeys('webdriver');
driver.findElement(webdriver.By.name('btnG')).click();
driver.quit();


For example, Node IP : 111.11.11.11:4444
and Hub IP is 222.22.22.22:5555

then how can i trigger the test on a Node using Hub. Please explain step by Step.


Many Thanks

Krishnan Mahadevan

unread,
Aug 3, 2015, 1:53:42 PM8/3/15
to Selenium Users
Here's a sample that worked for me against a hub+node running locally.

var webdriver = require('selenium-webdriver');
var driver = new webdriver.Builder()
            .usingServer('http://localhost:4444/wd/hub')
            .withCapabilities(webdriver.Capabilities.chrome())
            .build();
driver.get("http://www.google.com");
driver.getTitle().then(function(title) {
  console.log('Page title is: ' + title);
});
driver.quit();
console.log("Done");


Thanks & Regards
Krishnan Mahadevan

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"
My Scribblings @ http://wakened-cognition.blogspot.com/
My Technical Scribbings @ http://rationaleemotions.wordpress.com/

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-user...@googlegroups.com.
To post to this group, send email to seleniu...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/ceabf5c9-62d8-4929-8918-07c8e705c447%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages