Skip to content

Conversation

@alvarolaserna
Copy link
Contributor

Right now, using selenium grid 4.14.1 Testray doesnt work, adding this upgrade will make it work.

@TDL-EdgarsEglitis
Copy link
Collaborator

I think this code can be simplified. It looks like Selenium::WebDriver::Remote::Capabilities is deprecated, so we could try something like this:

  def build_chrome_driver(chrome_ops)
    chromeOptions = Selenium::WebDriver::Chrome::Options.new(
      options: chrome_ops,
    )
    if @url.nil?
      # local selenium instance
      driver = Selenium::WebDriver.for(
        :chrome, options: chromeOptions,
      )
    else
      # remote selenium grid
      log_debug("Selenium Server URL: #{@url}")
      driver = Selenium::WebDriver.for(
        :remote, url: @url, options: chromeOptions,
      )
    end
    return driver
  end

The equivalent code for other browsers should be similarly adjusted.

@alvarolaserna
Copy link
Contributor Author

I think this code can be simplified. It looks like Selenium::WebDriver::Remote::Capabilities is deprecated, so we could try something like this:

  def build_chrome_driver(chrome_ops)
    chromeOptions = Selenium::WebDriver::Chrome::Options.new(
      options: chrome_ops,
    )
    if @url.nil?
      # local selenium instance
      driver = Selenium::WebDriver.for(
        :chrome, options: chromeOptions,
      )
    else
      # remote selenium grid
      log_debug("Selenium Server URL: #{@url}")
      driver = Selenium::WebDriver.for(
        :remote, url: @url, options: chromeOptions,
      )
    end
    return driver
  end

The equivalent code for other browsers should be similarly adjusted.

I've modified it to cover that, the only one that Im not sure how to test is Safari, it doesnt seem to have any capabilities that I can try and work with... but for the rest of the browsers, everything goes as expected

@TDL-EdgarsEglitis
Copy link
Collaborator

Ok great - I can check it once you push the commit :)

@alvarolaserna
Copy link
Contributor Author

Ok great - I can check it once you push the commit :)

done

Copy link
Collaborator

@TDL-EdgarsEglitis TDL-EdgarsEglitis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should only use Selenium::WebDriver::<browser>::Options.new

@TDL-EdgarsEglitis
Copy link
Collaborator

I just realised that the code can be simplified even further:

  def build_chrome_driver(chrome_ops)
    chromeOptions = Selenium::WebDriver::Chrome::Options.new(
      options: chrome_ops,
    )
    if @url.nil?
      # local selenium instance
      Selenium::WebDriver.for(
        :chrome, options: chromeOptions,
      )
    else
      build_remote_driver(chromeOptions)
    end
  end
  
  # similar methods for other browser drivers
  
  def build_remote_driver(options)
    # remote selenium grid
    log_debug("Selenium Server URL: #{@url}")
    Selenium::WebDriver.for(
      :remote, url: @url, options: options,
    )
  end

@alvarolaserna
Copy link
Contributor Author

  def build_remote_driver(options)
    # remote selenium grid
    log_debug("Selenium Server URL: #{@url}")
    Selenium::WebDriver.for(
      :remote, url: @url, options: options,
    )
  end

Yes, this makes a lot of sense, thanks!

@alvarolaserna alvarolaserna merged commit e77b8c7 into master Nov 22, 2023
@TDL-EdgarsEglitis TDL-EdgarsEglitis deleted the update_selenium_dep branch May 20, 2024 08:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants