Class: Selenium::DevTools::V85::Emulation

Inherits:
Object
  • Object
show all
Defined in:
lib/selenium/devtools/v85/emulation.rb

Constant Summary collapse

EVENTS =
{
  virtual_time_budget_expired: 'virtualTimeBudgetExpired',
}.freeze

Instance Method Summary collapse

Constructor Details

#initialize(devtools) ⇒ Emulation

Returns a new instance of Emulation.



29
30
31
# File 'lib/selenium/devtools/v85/emulation.rb', line 29

def initialize(devtools)
  @devtools = devtools
end

Instance Method Details

#can_emulateObject



38
39
40
# File 'lib/selenium/devtools/v85/emulation.rb', line 38

def can_emulate
  @devtools.send_cmd('Emulation.canEmulate')
end

#clear_device_metrics_overrideObject



42
43
44
# File 'lib/selenium/devtools/v85/emulation.rb', line 42

def clear_device_metrics_override
  @devtools.send_cmd('Emulation.clearDeviceMetricsOverride')
end

#clear_geolocation_overrideObject



46
47
48
# File 'lib/selenium/devtools/v85/emulation.rb', line 46

def clear_geolocation_override
  @devtools.send_cmd('Emulation.clearGeolocationOverride')
end

#on(event, &block) ⇒ Object



33
34
35
36
# File 'lib/selenium/devtools/v85/emulation.rb', line 33

def on(event, &block)
  event = EVENTS[event] if event.is_a?(Symbol)
  @devtools.callbacks["Emulation.#{event}"] << block
end

#reset_page_scale_factorObject



50
51
52
# File 'lib/selenium/devtools/v85/emulation.rb', line 50

def reset_page_scale_factor
  @devtools.send_cmd('Emulation.resetPageScaleFactor')
end

#set_cpu_throttling_rate(rate:) ⇒ Object



59
60
61
62
# File 'lib/selenium/devtools/v85/emulation.rb', line 59

def set_cpu_throttling_rate(rate:)
  @devtools.send_cmd('Emulation.setCPUThrottlingRate',
                     rate: rate)
end

#set_default_background_color_override(color: nil) ⇒ Object



64
65
66
67
# File 'lib/selenium/devtools/v85/emulation.rb', line 64

def set_default_background_color_override(color: nil)
  @devtools.send_cmd('Emulation.setDefaultBackgroundColorOverride',
                     color: color)
end

#set_device_metrics_override(width:, height:, device_scale_factor:, mobile:, scale: nil, screen_width: nil, screen_height: nil, position_x: nil, position_y: nil, dont_set_visible_size: nil, screen_orientation: nil, viewport: nil) ⇒ Object



69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
# File 'lib/selenium/devtools/v85/emulation.rb', line 69

def set_device_metrics_override(width:, height:, device_scale_factor:, mobile:, scale: nil, screen_width: nil, screen_height: nil, position_x: nil, position_y: nil, dont_set_visible_size: nil, screen_orientation: nil, viewport: nil)
  @devtools.send_cmd('Emulation.setDeviceMetricsOverride',
                     width: width,
                     height: height,
                     deviceScaleFactor: device_scale_factor,
                     mobile: mobile,
                     scale: scale,
                     screenWidth: screen_width,
                     screenHeight: screen_height,
                     positionX: position_x,
                     positionY: position_y,
                     dontSetVisibleSize: dont_set_visible_size,
                     screenOrientation: screen_orientation,
                     viewport: viewport)
end


90
91
92
93
# File 'lib/selenium/devtools/v85/emulation.rb', line 90

def set_document_cookie_disabled(disabled:)
  @devtools.send_cmd('Emulation.setDocumentCookieDisabled',
                     disabled: disabled)
end

#set_emit_touch_events_for_mouse(enabled:, configuration: nil) ⇒ Object



95
96
97
98
99
# File 'lib/selenium/devtools/v85/emulation.rb', line 95

def set_emit_touch_events_for_mouse(enabled:, configuration: nil)
  @devtools.send_cmd('Emulation.setEmitTouchEventsForMouse',
                     enabled: enabled,
                     configuration: configuration)
end

#set_emulated_media(media: nil, features: nil) ⇒ Object



101
102
103
104
105
# File 'lib/selenium/devtools/v85/emulation.rb', line 101

def set_emulated_media(media: nil, features: nil)
  @devtools.send_cmd('Emulation.setEmulatedMedia',
                     media: media,
                     features: features)
end

#set_emulated_vision_deficiency(type:) ⇒ Object



107
108
109
110
# File 'lib/selenium/devtools/v85/emulation.rb', line 107

def set_emulated_vision_deficiency(type:)
  @devtools.send_cmd('Emulation.setEmulatedVisionDeficiency',
                     type: type)
end

#set_focus_emulation_enabled(enabled:) ⇒ Object



54
55
56
57
# File 'lib/selenium/devtools/v85/emulation.rb', line 54

def set_focus_emulation_enabled(enabled:)
  @devtools.send_cmd('Emulation.setFocusEmulationEnabled',
                     enabled: enabled)
end

#set_geolocation_override(latitude: nil, longitude: nil, accuracy: nil) ⇒ Object



112
113
114
115
116
117
# File 'lib/selenium/devtools/v85/emulation.rb', line 112

def set_geolocation_override(latitude: nil, longitude: nil, accuracy: nil)
  @devtools.send_cmd('Emulation.setGeolocationOverride',
                     latitude: latitude,
                     longitude: longitude,
                     accuracy: accuracy)
end

#set_locale_override(locale: nil) ⇒ Object



149
150
151
152
# File 'lib/selenium/devtools/v85/emulation.rb', line 149

def set_locale_override(locale: nil)
  @devtools.send_cmd('Emulation.setLocaleOverride',
                     locale: locale)
end

#set_navigator_overrides(platform:) ⇒ Object



119
120
121
122
# File 'lib/selenium/devtools/v85/emulation.rb', line 119

def set_navigator_overrides(platform:)
  @devtools.send_cmd('Emulation.setNavigatorOverrides',
                     platform: platform)
end

#set_page_scale_factor(page_scale_factor:) ⇒ Object



124
125
126
127
# File 'lib/selenium/devtools/v85/emulation.rb', line 124

def set_page_scale_factor(page_scale_factor:)
  @devtools.send_cmd('Emulation.setPageScaleFactor',
                     pageScaleFactor: page_scale_factor)
end

#set_script_execution_disabled(value:) ⇒ Object



129
130
131
132
# File 'lib/selenium/devtools/v85/emulation.rb', line 129

def set_script_execution_disabled(value:)
  @devtools.send_cmd('Emulation.setScriptExecutionDisabled',
                     value: value)
end

#set_scrollbars_hidden(hidden:) ⇒ Object



85
86
87
88
# File 'lib/selenium/devtools/v85/emulation.rb', line 85

def set_scrollbars_hidden(hidden:)
  @devtools.send_cmd('Emulation.setScrollbarsHidden',
                     hidden: hidden)
end

#set_timezone_override(timezone_id:) ⇒ Object



154
155
156
157
# File 'lib/selenium/devtools/v85/emulation.rb', line 154

def set_timezone_override(timezone_id:)
  @devtools.send_cmd('Emulation.setTimezoneOverride',
                     timezoneId: timezone_id)
end

#set_touch_emulation_enabled(enabled:, max_touch_points: nil) ⇒ Object



134
135
136
137
138
# File 'lib/selenium/devtools/v85/emulation.rb', line 134

def set_touch_emulation_enabled(enabled:, max_touch_points: nil)
  @devtools.send_cmd('Emulation.setTouchEmulationEnabled',
                     enabled: enabled,
                     maxTouchPoints: max_touch_points)
end

#set_user_agent_override(user_agent:, accept_language: nil, platform: nil, user_agent_metadata: nil) ⇒ Object



165
166
167
168
169
170
171
# File 'lib/selenium/devtools/v85/emulation.rb', line 165

def set_user_agent_override(user_agent:, accept_language: nil, platform: nil, user_agent_metadata: nil)
  @devtools.send_cmd('Emulation.setUserAgentOverride',
                     userAgent: user_agent,
                     acceptLanguage: accept_language,
                     platform: platform,
                     userAgentMetadata: )
end

#set_virtual_time_policy(policy:, budget: nil, max_virtual_time_task_starvation_count: nil, wait_for_navigation: nil, initial_virtual_time: nil) ⇒ Object



140
141
142
143
144
145
146
147
# File 'lib/selenium/devtools/v85/emulation.rb', line 140

def set_virtual_time_policy(policy:, budget: nil, max_virtual_time_task_starvation_count: nil, wait_for_navigation: nil, initial_virtual_time: nil)
  @devtools.send_cmd('Emulation.setVirtualTimePolicy',
                     policy: policy,
                     budget: budget,
                     maxVirtualTimeTaskStarvationCount: max_virtual_time_task_starvation_count,
                     waitForNavigation: wait_for_navigation,
                     initialVirtualTime: initial_virtual_time)
end

#set_visible_size(width:, height:) ⇒ Object



159
160
161
162
163
# File 'lib/selenium/devtools/v85/emulation.rb', line 159

def set_visible_size(width:, height:)
  @devtools.send_cmd('Emulation.setVisibleSize',
                     width: width,
                     height: height)
end