Class: Applitools::Selenium::Configuration
- Inherits:
-
EyesBaseConfiguration
- Object
- EyesBaseConfiguration
- Applitools::Selenium::Configuration
- Defined in:
- lib/applitools/selenium/configuration.rb
Constant Summary collapse
- DEFAULT_CONFIG =
proc do { # force_full_page_screenshot: false, wait_before_screenshots: 0.1, # stitch_mode: Applitools::Selenium::StitchModes::CSS, hide_scrollbars: true, hide_caret: false, browsers_info: Applitools::Selenium::BrowsersInfo.new, rendering_grid_force_put: (ENV['APPLITOOLS_RENDERING_GRID_FORCE_PUT'] || 'false').casecmp('true') == 0, visual_grid_options: {} } end
Class Method Summary collapse
Instance Method Summary collapse
- #add_browser(*args) {|Applitools::Selenium::RenderBrowserInfoFluent.new(browser)| ... } ⇒ Object
- #add_browsers(*browsers) ⇒ Object
- #add_device_emulation(device_name, orientation = Orientations::PORTRAIT) ⇒ Object
- #add_mobile_device(mobile_device_info) ⇒ Object
- #add_mobile_devices(mobile_device_infos) ⇒ Object
- #add_multi_device_target(*args) ⇒ Object
- #custom_setter_for_visual_grid_options(value) ⇒ Object
-
#viewport_size ⇒ Object
Move viewport_size above the private methods.
Class Method Details
.default_config ⇒ Object
22 23 24 |
# File 'lib/applitools/selenium/configuration.rb', line 22 def default_config super.merge DEFAULT_CONFIG.call end |
Instance Method Details
#add_browser(*args) {|Applitools::Selenium::RenderBrowserInfoFluent.new(browser)| ... } ⇒ Object
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/applitools/selenium/configuration.rb', line 68 def add_browser(*args) case args.size when 0 browser = Applitools::Selenium::DesktopBrowserInfo.new when 1 b = args[0] raise( Applitools::EyesIllegalArgument, 'Expected :browser to be an IRenderBrowserInfo instance!' ) unless b.is_a? IRenderBrowserInfo browser = b when 3 browser = Applitools::Selenium::DesktopBrowserInfo.new.tap do |bi| bi. = Applitools::RectangleSize.new(args[0], args[1]) bi.browser_type = args[2] end end yield(Applitools::Selenium::RenderBrowserInfoFluent.new(browser)) if block_given? browsers_info.add browser # self.viewport_size = browser.viewport_size unless viewport_size self end |
#add_browsers(*browsers) ⇒ Object
91 92 93 94 95 96 97 98 99 100 101 102 |
# File 'lib/applitools/selenium/configuration.rb', line 91 def add_browsers(*browsers) browsers = case browsers.first when Applitools::Selenium::IRenderBrowserInfo browsers when Array browsers.first end browsers.each do |browser| add_browser(browser) end self end |
#add_device_emulation(device_name, orientation = Orientations::PORTRAIT) ⇒ Object
104 105 106 107 108 109 |
# File 'lib/applitools/selenium/configuration.rb', line 104 def add_device_emulation(device_name, orientation = Orientations::PORTRAIT) Applitools::ArgumentGuard.not_nil device_name, 'device_name' raise Applitools::EyesIllegalArgument, 'Wrong device name!' unless Devices.enum_values.include? device_name emu = Applitools::Selenium::ChromeEmulationInfo.new(device_name, orientation) add_browser emu end |
#add_mobile_device(mobile_device_info) ⇒ Object
111 112 113 |
# File 'lib/applitools/selenium/configuration.rb', line 111 def add_mobile_device(mobile_device_info) add_mobile_devices(mobile_device_info) end |
#add_mobile_devices(mobile_device_infos) ⇒ Object
115 116 117 |
# File 'lib/applitools/selenium/configuration.rb', line 115 def add_mobile_devices(mobile_device_infos) add_browsers(mobile_device_infos) end |
#add_multi_device_target(*args) ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/applitools/selenium/configuration.rb', line 45 def add_multi_device_target(*args) ios_devices = [] if args.length == 1 && args[0].is_a?(Hash) # Single hash passed directly ios_devices << create_ios_device_info(args[0]) elsif args.any? { |arg| arg.is_a?(Hash) } # One of the arguments is a hash with device configuration hash_arg = args.find { |arg| arg.is_a?(Hash) } ios_devices << create_ios_device_info(hash_arg) else # Multiple device names as symbols or strings args.each do |device_name| ios_devices << create_ios_device_info(device_name: device_name) end end # Add each iOS device to the configuration add_browsers(*ios_devices) # Return the configuration object for method chaining self end |
#custom_setter_for_visual_grid_options(value) ⇒ Object
40 41 42 43 |
# File 'lib/applitools/selenium/configuration.rb', line 40 def (value) return {} if value.nil? value end |
#viewport_size ⇒ Object
Move viewport_size above the private methods
120 121 122 123 124 125 126 127 |
# File 'lib/applitools/selenium/configuration.rb', line 120 def user_defined_vp = super user_defined_vp = nil if user_defined_vp.respond_to?(:square) && user_defined_vp.square == 0 return user_defined_vp if user_defined_vp # from_browsers_info = browsers_info.select { |bi| bi.viewport_size.square > 0 }.first # return from_browsers_info.viewport_size if from_browsers_info nil end |