Class: Selenium::DevTools::V85::Target

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

Constant Summary collapse

EVENTS =
{
  attached_to_target: 'attachedToTarget',
  detached_from_target: 'detachedFromTarget',
  received_message_from_target: 'receivedMessageFromTarget',
  target_created: 'targetCreated',
  target_destroyed: 'targetDestroyed',
  target_crashed: 'targetCrashed',
  target_info_changed: 'targetInfoChanged',
}.freeze

Instance Method Summary collapse

Constructor Details

#initialize(devtools) ⇒ Target

Returns a new instance of Target.



35
36
37
# File 'lib/selenium/devtools/v85/target.rb', line 35

def initialize(devtools)
  @devtools = devtools
end

Instance Method Details

#activate_target(target_id:) ⇒ Object



44
45
46
47
# File 'lib/selenium/devtools/v85/target.rb', line 44

def activate_target(target_id:)
  @devtools.send_cmd('Target.activateTarget',
                     targetId: target_id)
end

#attach_to_browser_targetObject



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

def attach_to_browser_target
  @devtools.send_cmd('Target.attachToBrowserTarget')
end

#attach_to_target(target_id:, flatten: nil) ⇒ Object



49
50
51
52
53
# File 'lib/selenium/devtools/v85/target.rb', line 49

def attach_to_target(target_id:, flatten: nil)
  @devtools.send_cmd('Target.attachToTarget',
                     targetId: target_id,
                     flatten: flatten)
end

#close_target(target_id:) ⇒ Object



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

def close_target(target_id:)
  @devtools.send_cmd('Target.closeTarget',
                     targetId: target_id)
end

#create_browser_context(dispose_on_detach: nil, proxy_server: nil, proxy_bypass_list: nil) ⇒ Object



70
71
72
73
74
75
# File 'lib/selenium/devtools/v85/target.rb', line 70

def create_browser_context(dispose_on_detach: nil, proxy_server: nil, proxy_bypass_list: nil)
  @devtools.send_cmd('Target.createBrowserContext',
                     disposeOnDetach: dispose_on_detach,
                     proxyServer: proxy_server,
                     proxyBypassList: proxy_bypass_list)
end

#create_target(url:, width: nil, height: nil, browser_context_id: nil, enable_begin_frame_control: nil, new_window: nil, background: nil) ⇒ Object



81
82
83
84
85
86
87
88
89
90
# File 'lib/selenium/devtools/v85/target.rb', line 81

def create_target(url:, width: nil, height: nil, browser_context_id: nil, enable_begin_frame_control: nil, new_window: nil, background: nil)
  @devtools.send_cmd('Target.createTarget',
                     url: url,
                     width: width,
                     height: height,
                     browserContextId: browser_context_id,
                     enableBeginFrameControl: enable_begin_frame_control,
                     newWindow: new_window,
                     background: background)
end

#detach_from_target(session_id: nil, target_id: nil) ⇒ Object



92
93
94
95
96
# File 'lib/selenium/devtools/v85/target.rb', line 92

def detach_from_target(session_id: nil, target_id: nil)
  @devtools.send_cmd('Target.detachFromTarget',
                     sessionId: session_id,
                     targetId: target_id)
end

#dispose_browser_context(browser_context_id:) ⇒ Object



98
99
100
101
# File 'lib/selenium/devtools/v85/target.rb', line 98

def dispose_browser_context(browser_context_id:)
  @devtools.send_cmd('Target.disposeBrowserContext',
                     browserContextId: browser_context_id)
end

#expose_dev_tools_protocol(target_id:, binding_name: nil) ⇒ Object



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

def expose_dev_tools_protocol(target_id:, binding_name: nil)
  @devtools.send_cmd('Target.exposeDevToolsProtocol',
                     targetId: target_id,
                     bindingName: binding_name)
end

#get_browser_contextsObject



77
78
79
# File 'lib/selenium/devtools/v85/target.rb', line 77

def get_browser_contexts
  @devtools.send_cmd('Target.getBrowserContexts')
end

#get_target_info(target_id: nil) ⇒ Object



103
104
105
106
# File 'lib/selenium/devtools/v85/target.rb', line 103

def get_target_info(target_id: nil)
  @devtools.send_cmd('Target.getTargetInfo',
                     targetId: target_id)
end

#get_targetsObject



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

def get_targets
  @devtools.send_cmd('Target.getTargets')
end

#on(event, &block) ⇒ Object



39
40
41
42
# File 'lib/selenium/devtools/v85/target.rb', line 39

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

#send_message_to_target(message:, session_id: nil, target_id: nil) ⇒ Object



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

def send_message_to_target(message:, session_id: nil, target_id: nil)
  @devtools.send_cmd('Target.sendMessageToTarget',
                     message: message,
                     sessionId: session_id,
                     targetId: target_id)
end

#set_auto_attach(auto_attach:, wait_for_debugger_on_start:, flatten: nil) ⇒ Object



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

def set_auto_attach(auto_attach:, wait_for_debugger_on_start:, flatten: nil)
  @devtools.send_cmd('Target.setAutoAttach',
                     autoAttach: auto_attach,
                     waitForDebuggerOnStart: wait_for_debugger_on_start,
                     flatten: flatten)
end

#set_discover_targets(discover:) ⇒ Object



126
127
128
129
# File 'lib/selenium/devtools/v85/target.rb', line 126

def set_discover_targets(discover:)
  @devtools.send_cmd('Target.setDiscoverTargets',
                     discover: discover)
end

#set_remote_locations(locations:) ⇒ Object



131
132
133
134
# File 'lib/selenium/devtools/v85/target.rb', line 131

def set_remote_locations(locations:)
  @devtools.send_cmd('Target.setRemoteLocations',
                     locations: locations)
end