2

I have register two platform with chrome browser on windows 7 and windows 10 into selenium grid server.

I want to run a test at Chrome browser on Windows 10 but when i run the test, the test randomly run on Windows 7 and randomly run on Windows 10 on chrome.

Do you have an idea how to do the configuration to run the test on specific browser and platform when we have registered multiple platform?

hub:

java -jar selenium-server-standalone-3.7.1.jar -role hub

register node on windows 7:

java -Dwebdriver.chrome.driver=chromedriver_2.33.exe -jar selenium-server-standalone-3.7.1.jar -role node -hub http://localhost:4444

register node on windows 10:

java -Dwebdriver.chrome.driver=chromedriver_2.33.exe -jar selenium-server-standalone-3.7.1.jar -role node -hub http://localhost:4444

protractor.conf.js

exports.config = {

    specs: [
        '**/*.mytest.e2e-spec.ts'
    ],
    multiCapabilities: [
        {
            browserName: 'chrome',
            platform: 'WIN10',
        }
    ],
    seleniumAddress: 'http://localhost:4444/wd/hub',
    baseUrl: 'http://localhost:4200/',
    framework: 'jasmine',
    jasmineNodeOpts: {
        print: function () {
        }
    },
    onPrepare: function () {
        require('ts-node').register({
            project: 'e2e/tsconfig.e2e.json'
        });
    }
};
Jan
  • 125
  • 1
  • 9

4 Answers4

1

Selenium Grid Installation Process:-

  1. Download Selenium server standalone jar file in which you want to create Hub
  2. Create a new java project and add it to build path

Start the Hub Using Below Command in your machine:-

  1. java -jar selenium-server-standalone-3.9.1.jar –role hub -port 4446

  2. Open ip address/grid/console in host browser "or" localhost: portnumber/grid/console

Start the Node Using Below Command in another machine:

  1. Download Selenium server standalone jar file in another laptop

  2. it is not necessary that node contains eclipse. But Java Should be installed.

  3. go to file path where selenium standalone is kept

  4. Type Below command

  5. java -jar selenium-server-standalone-3.9.1.jar –role webdriver –hub ipaddress/grid/ register –port 5566

(but Here your test will fail because here file path for chrome Driver or gecko driver is not provided in the hub.)

  1. java –Dwebdriver.chrome.driver="provide path for chrome driver" -jar selenium-server-standalone-3.9.1.jar –role webdriver –hub ipaddress/grid/register –port 5566
Alok Ranjan
  • 111
  • 1
  • 5
0

You need to tweak the commands for registering the nodes as follows :

  • Register node on Windows 7:

    java -Dwebdriver.chrome.driver=chromedriver_2.33.exe -jar selenium-server-standalone-3.7.1.jar -role node -hub http://localhost:4444/grid/register
    
  • Register node on Windows 10:

    java -Dwebdriver.chrome.driver=chromedriver_2.33.exe -jar selenium-server-standalone-3.7.1.jar -role node -hub http://localhost:4444/grid/register
    
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
  • i have done it, after that it is just display chrome browser in selenium grid for both register nodes. but still not run test on specific platform on Chrome. i don't have problem with registering node. just i want to run test on Chrome browser on win7? – Jan Dec 04 '17 at 12:35
  • My Answer was as per your Question `Do you have an idea how to do the configuration to run the test on specific browser and platform`. Your `Node Registration` process was error prone. Now to `run test` you need to write script to execute. Please mark the Answer as Accepted by clicking on the tick mark beside my Answer which is just below the VoteDown arrow so the tick mark turns green. – undetected Selenium Dec 04 '17 at 12:43
0

As per your question and DebanjanB answer, You have two nodes and two hubs. You need to register the nodes with same hub. Please try with following configuration, it may works.

  1. Start your hub on windows 7 Machine with following command,

    java -jar selenium-server-standalone-3.7.1.jar -role hub

  2. Start/register your first node on windows 7 with following command,

    java -Dwebdriver.chrome.driver=chromedriver_2.33.exe -jar selenium-server-standalone-3.7.1.jar -role node

  3. start/register your second node on windows 10 with following command,

    java -Dwebdriver.chrome.driver=chromedriver_2.33.exe -jar selenium-server-standalone-3.7.1.jar -role node -hub http://"IP Address OF Windows 7 machine":4444/grid/register

  4. To verify the nodes are listed on hub, just open the url http://localhost:4444/grid/console on windows 7 machine. Then, verify your nodes are listed on the page.

  5. You have to run your script from the windows 7 machine because your selenium address is using localhost address( seleniumAddress: 'http://localhost:4444/wd/hub'). if you want to run from windows 10 machine or any other machine. change the selenium address as 'http://"windows7ipaddress":4444/wd/hub' in config file.

I have tested it on my machine it is working fine. It will start the chrome on windows 10 machine as your multiCapabilities platform value is WIN10.

note: replace the value of ip address value in place where ever required.

Murthi
  • 5,299
  • 1
  • 10
  • 15
  • i have done all your steps but when i have just win10 on my config instate of running test on win10(chrome) test run on win7(chrom), i thing the problem is my configuration file , i have to some how specified the target platform and browser. – Jan Dec 04 '17 at 15:05
  • do you know how to specified exact browser and platform to run when we have several platform and browser already registered into server? – Jan Dec 04 '17 at 15:30
  • Yes, you to need to give browser name and platform in the config file – Murthi Dec 04 '17 at 15:33
  • And if we give both platform then, it will execute on both machine in parallel – Murthi Dec 04 '17 at 15:36
0

I would suggest that you do the following

  • Create a node configuration file as seen here, wherein for the WINDOWS7 node, you specify the appropriate platform (make sure you pick a value from here)
  • Now you start off the node by specifying this newly created nodeConfig json using the command line parameter -nodeConfig node.json ( For more details refer to my blog post here )

Now based on the PLATFORM capabilities specified by your test, it would be routed to the appropriate node.

Krishnan Mahadevan
  • 14,121
  • 6
  • 34
  • 66