How to manually specify startup port for chromeDrive

995 views
Skip to first unread message

tejesh kumar reddy nagi reddy

unread,
Apr 26, 2019, 2:06:58 PM4/26/19
to ChromeDriver Users

Hi Team,

I am running tests parallel with parallel_tests gem and so far all things are good and successfully able to incorporate in cloud environemnt also. But in some cases, our tests have quite and re-open browser. It is like @driver.quit which kills browser and chromedriver also and then browser is re-launched with new chrome session.

At this stage i don't have any chrome browser or chromedriver session running. So when relaunched with new driver session, sometimes it is starting on 9515 and sometimes on 9516.
9515 port is always opened and when it launches driver on 9515 there is no issue and test is passing successfully, but when driver session launched on 9516. It is saying unable to establish connection and tests are failing.

Not sure if parallel_tests taking ports randomly or chromedriver issues. Any help is appreciated? & has anyone faced this sort of issues?

i am using parallel_tests 2.27.1
chrome version 68(tried on 73 also)


When I posted this question to parallel_tests project in git hub, he suggested to configure multiple capybara server ports in the project. Find the link below:

https://github.com/grosser/parallel_tests/issues/691


I have tried to configure in spec_helper.rb while registering the driver as below but no luck. 


if @browser == 'chrome' || @browser == "ch" || @browser == 'default'

          Capybara.configure do |config|

          config.server_port = 9887 + ENV['TEST_ENV_NUMBER'].to_i

          end

          Capybara.register_driver :selenium do |app|

            profile = Selenium::WebDriver::Chrome::Profile.new

            profile['extensions.password_manager_enabled'] = false

          caps = Selenium::WebDriver::Remote::Capabilities.chrome(

              "chromeOptions" =>

              {

                "args" => [ "--start-maximized", "--test-type", "--disable-popup-blocking", "--disable-infobars" ],

                "prefs" => { "profile.managed_default_content_settings.geolocation" => 1, "profile.password_manager_enabled" => false, "credentials_enable_service" => false }

              }

            )

            @driver = Capybara::Selenium::Driver.new(app, {:browser => :chrome, :desired_capabilities => caps, :http_client => client})

          end 

I got a reply from the capybara team saying as below when I reach out them:

"Chromedriver, by default, runs on port 9515 - If you're running parallel tests though each instance of chromedriver would need to be assigned a different port to open on (just like you've done with the Capybara server port)

That would be something like

    @driver = Capybara::Selenium::Driver.new, browser: :chrome, desired_capabilities: caps, http_client: client, port: (9515 + ENV['TEST_ENV_NUMBER'].to_i))

The latest selenium-webdriver is deprecating passing the :port option and taking a :service option instead - Unfortunately I don't remember the exact usage of that at the moment, but if setting a port fixes your issue it should be easy enough to work out".

Please help me out on this issue how to handle. Is there a way to handle this situation.


Thanks,
Tejesh

Artur Khachatryan

unread,
Apr 26, 2019, 3:01:32 PM4/26/19
to tejesh kumar reddy nagi reddy, ChromeDriver Users

x = 0

Capybara.configure do |config|

              x += 1

          config.server_port = 9887 + x

          end


--
You received this message because you are subscribed to the Google Groups "ChromeDriver Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chromedriver-us...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages