Protractor - What is the difference between seleniumAddress and directConnect

1k Views Asked by At

I'm not clear about what's the difference between run my protractor tests using:

directConnect: true/false,
seleniumAddress: 'http://localhost:4444/wd/hub',

And also, why this is working? What I'm using for run my tests?

I've not declare any of the above options in my config file, and I've all my tests running.

This is the output when I run my tests:

[16:26:42] I/launcher - Running 1 instances of WebDriver
[16:26:42] I/local - Starting selenium standalone server...
[16:26:46] I/local - Selenium standalone server started at http://193.167.1.94:57674/wd/hub

I/local means that I'm running locally? Is directConnect the default option?

I saw I/hosted in some stack overflow post. That means that they are using an external grid?

2

There are 2 best solutions below

6
yong On BEST ANSWER

seleniumAddress

You can give selenium server or selenium grid url to seleniumAddress.

You can start selenium server or grid on same or diff machine where test

script reside

1.1) local selenium server

 . Selenium server run on same machine where test scripts reside

 . When running test, browser opened on the machine where selenium server running

 . Communicate Path:  ( in same machine where test script reside)

    test script -> selenium server -> webdriver binary -> browser

1.2) remote selenium server

. Selenium server run on remote machine where test scripts **NOT** reside

. When running test, browser opened on the remote machine where selenium server running  

. Communicate Path: ( cross two machines )

   test script -> test script machine 
               -> selenium server  (on remote machine)
               -> webdriver binary (on remote machine)
               -> browser          (on remote machine)

1.3) selenium grid

. Grid use Master/Slave 

. Multiple Slave machines register to One Master machine

. Each Slave can install couple kinds of browsers

. Slave tell Master it can provide the kinds of browser and 
  max browser instances running in parallel when register to Master

. Master will determine each test open browser on which Slave 
  by test required browser type and not exceed the max browser instances on slave

. Communicate Path: ( cross three machines )

    test script -> test script machine 
                -> master machine
                -> selenium server  (on choosen slave machine)
                -> webdriver binary (on choosen slave machine)
                -> browser          (on choosen slave machine)

directConnect

. When directConnect: true, seleniumAddress will be ignored (if both configured)

. Only chrome and firefox support directConnect so far

. Communicate Path: ( in same machine where test script reside) 

    test script -> webdriver binary -> browser

Using seleniumAddress you can see the logs of test script communicate to webdriver in the terminate window where you start the selenium server/grid.

From the logs you can get information like following:

  • test script use which locator to find element
  • the step to find/operate element complete or failed
  • when test case failed, it failed on communicating which element.

These information is very useful to debug test script

Using directConnect by default protractor won't start webdriver binary in separate terminate window and won't direct the communicate log into file.

So it's not suite for debug test script.

2
DublinDev On

seleniumAddress is the location where the selenium server is running. If this is not specified then a new selenium server instance will be created when your framework is executed (usually on the default selenium port 4444).

directConnect is different, it allows you to send command directly to the browser drivers, skipping the seleniumServer altogether. It's definition according to the conf linked below is:

If true, Protractor will connect directly to the browser Drivers at the locations specified by chromeDriver and firefoxPath. Only Chrome and Firefox are supported for direct connect.

This is a link to the sample conf.ts file with all options and explanations listed along the default settings. I find it a very useful reference.

Also see this relevant prior thread for more information.