Search code examples
selenium-webdriverprotractorselenium-gridselenium-server

Protractor - What is the difference between seleniumAddress and directConnect


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?


Solution

  • 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.