Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ruby] fix: setting w3c: false throws error #10918

Merged
merged 2 commits into from
Aug 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
22 changes: 22 additions & 0 deletions rb/lib/selenium/webdriver/remote/bridge.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ def initialize(url:, http_client: nil)
#

def create_session(capabilities)
check_chrome_w3c_false(capabilities)
response = execute(:new_session, {}, prepare_capabilities_payload(capabilities))

@session_id = response['sessionId']
Expand Down Expand Up @@ -666,6 +667,27 @@ def escape_css(string)

string
end

#
# Checks if w3c key is set to false and raises error for the same.
#
def check_chrome_w3c_false(capabilities)
return unless capabilities['browserName'] == 'chrome' && capabilities.key?('goog:chromeOptions')

capability = capabilities['goog:chromeOptions']
w3c = true

if capability.instance_of?(Hash)
raw_w3c = capability['w3c']
w3c = raw_w3c.nil? || raw_w3c
end

return if w3c

raise Error::WebDriverError, "Setting 'w3c: false' is not allowed.\n"\
"Please update to W3C Syntax: https://www"\
".selenium.dev/blog/2022/legacy-protocol-support/"
end
end # Bridge
end # Remote
end # WebDriver
Expand Down
5 changes: 5 additions & 0 deletions rb/spec/integration/selenium/webdriver/driver_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@ module WebDriver
end
end

it 'should raise error when w3c is false', exclusive: {browser: %i[chrome]} do
options = Selenium::WebDriver::Chrome::Options.new(w3c: false)
expect { Selenium::WebDriver.for :chrome, capabilities: options }.to raise_error(Error::WebDriverError)
end

it 'should get driver status' do
status = driver.status
expect(status).to include('ready', 'message')
Expand Down