Class: Puppeteer::BrowserContext
- Inherits:
-
Object
- Object
- Puppeteer::BrowserContext
show all
- Includes:
- EventCallbackable
- Defined in:
- lib/puppeteer/browser_context.rb
Instance Method Summary
collapse
#add_event_listener, #emit_event, #observe_first, #on_event, #remove_event_listener
Constructor Details
#initialize(connection, browser, context_id) ⇒ BrowserContext
Returns a new instance of BrowserContext.
7
8
9
10
11
|
# File 'lib/puppeteer/browser_context.rb', line 7
def initialize(connection, browser, context_id)
@connection = connection
@browser = browser
@id = context_id
end
|
Instance Method Details
80
81
82
|
# File 'lib/puppeteer/browser_context.rb', line 80
def browser
@browser
end
|
#close ⇒ Object
84
85
86
87
88
89
|
# File 'lib/puppeteer/browser_context.rb', line 84
def close
if !@id
raise 'Non-incognito profiles cannot be closed!'
end
@browser.dispose_context(@id)
end
|
#incognito? ⇒ Boolean
33
34
35
|
# File 'lib/puppeteer/browser_context.rb', line 33
def incognito?
!@id
end
|
75
76
77
|
# File 'lib/puppeteer/browser_context.rb', line 75
def new_page
@browser.create_page_in_context(@id)
end
|
#pages ⇒ !Promise<!Array<!Puppeteer.Page>>
29
30
31
|
# File 'lib/puppeteer/browser_context.rb', line 29
def pages
targets.select { |target| target.type == 'page' }.map(&:page).reject { |page| !page }
end
|
#targets ⇒ !Array<!Target>
14
15
16
|
# File 'lib/puppeteer/browser_context.rb', line 14
def targets
@browser.targets.select { |target| target.browser_context == self }
end
|
#wait_for_target(predicate:, timeout: nil) ⇒ !Promise<!Target>
21
22
23
24
25
26
|
# File 'lib/puppeteer/browser_context.rb', line 21
def wait_for_target(predicate:, timeout: nil)
@browser.wait_for_target(
predicate: ->(target) { target.browser_context == self && predicate.call(target) },
timeout: timeout,
)
end
|