diff --git a/rb/lib/selenium/webdriver/chrome/bridge.rb b/rb/lib/selenium/webdriver/chrome/bridge.rb index d3a55c624cb0e..c6e817802e90d 100644 --- a/rb/lib/selenium/webdriver/chrome/bridge.rb +++ b/rb/lib/selenium/webdriver/chrome/bridge.rb @@ -22,7 +22,8 @@ module Bridge COMMANDS = { get_network_conditions: [:get, '/session/:session_id/chromium/network_conditions'.freeze], - set_network_conditions: [:post, '/session/:session_id/chromium/network_conditions'.freeze] + set_network_conditions: [:post, '/session/:session_id/chromium/network_conditions'.freeze], + send_command: [:post, '/session/:session_id/chromium/send_command'.freeze] }.freeze def commands(command) @@ -33,6 +34,10 @@ def network_conditions execute :get_network_conditions end + def send_command(command_params) + execute :send_command, {}, command_params + end + def network_conditions=(conditions) execute :set_network_conditions, {}, {network_conditions: conditions} end diff --git a/rb/lib/selenium/webdriver/chrome/driver.rb b/rb/lib/selenium/webdriver/chrome/driver.rb index 33254c299f992..89ae71df092be 100644 --- a/rb/lib/selenium/webdriver/chrome/driver.rb +++ b/rb/lib/selenium/webdriver/chrome/driver.rb @@ -29,6 +29,7 @@ class Driver < WebDriver::Driver include DriverExtensions::HasTouchScreen include DriverExtensions::HasWebStorage include DriverExtensions::TakesScreenshot + include DriverExtensions::DownloadsFiles def initialize(opts = {}) opts[:desired_capabilities] = create_capabilities(opts) diff --git a/rb/lib/selenium/webdriver/common.rb b/rb/lib/selenium/webdriver/common.rb index 0b21623707952..f1277bb2e507b 100644 --- a/rb/lib/selenium/webdriver/common.rb +++ b/rb/lib/selenium/webdriver/common.rb @@ -50,6 +50,7 @@ require 'selenium/webdriver/common/driver_extensions/takes_screenshot' require 'selenium/webdriver/common/driver_extensions/rotatable' require 'selenium/webdriver/common/driver_extensions/has_web_storage' +require 'selenium/webdriver/common/driver_extensions/downloads_files' require 'selenium/webdriver/common/driver_extensions/has_location' require 'selenium/webdriver/common/driver_extensions/has_session_id' require 'selenium/webdriver/common/driver_extensions/has_touch_screen' diff --git a/rb/lib/selenium/webdriver/common/driver_extensions/downloads_files.rb b/rb/lib/selenium/webdriver/common/driver_extensions/downloads_files.rb new file mode 100644 index 0000000000000..e5b5797696131 --- /dev/null +++ b/rb/lib/selenium/webdriver/common/driver_extensions/downloads_files.rb @@ -0,0 +1,39 @@ +# Licensed to the Software Freedom Conservancy (SFC) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The SFC licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +module Selenium + module WebDriver + module DriverExtensions + module DownloadsFiles + + # + # sets downloading of files to spcified location + # + # + + def downloads_files_to(path:"tmp") + params = { + 'cmd' =>'Page.setDownloadBehavior', + "params" => {"behavior" => 'allow', 'downloadPath' => path } + } + @bridge.send_command(params) + end + + end # HasNetworkConditions + end # DriverExtensions + end # WebDriver +end # Selenium