Class: Browserctl::PageProxy

Inherits:
Object
  • Object
show all
Defined in:
lib/browserctl/workflow.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, client, replay_context: nil, matcher: nil) ⇒ PageProxy

Returns a new instance of PageProxy.



304
305
306
307
308
309
# File 'lib/browserctl/workflow.rb', line 304

def initialize(name, client, replay_context: nil, matcher: nil)
  @name           = name
  @client         = client
  @replay_context = replay_context
  @matcher        = matcher || Replay::FingerprintMatcher.new
end

Instance Attribute Details

#replay_contextObject

Returns the value of attribute replay_context.



302
303
304
# File 'lib/browserctl/workflow.rb', line 302

def replay_context
  @replay_context
end

Instance Method Details

#click(selector = nil, ref: nil) ⇒ Object



319
320
321
322
323
# File 'lib/browserctl/workflow.rb', line 319

def click(selector = nil, ref: nil)
  with_selector_fallback(:click, selector, ref) do |sel, r|
    @client.click(@name, sel, ref: r)
  end
end

#delete_cookiesObject



328
# File 'lib/browserctl/workflow.rb', line 328

def delete_cookies             = unwrap @client.delete_cookies(@name)

#devtoolsObject



329
# File 'lib/browserctl/workflow.rb', line 329

def devtools                   = @client.devtools(@name)[:devtools_url]

#dialog_accept(text: nil) ⇒ Object



361
# File 'lib/browserctl/workflow.rb', line 361

def dialog_accept(text: nil) = unwrap @client.dialog_accept(@name, text: text)

#dialog_dismissObject



362
# File 'lib/browserctl/workflow.rb', line 362

def dialog_dismiss           = unwrap @client.dialog_dismiss(@name)

#evaluate(expr) ⇒ Object



331
# File 'lib/browserctl/workflow.rb', line 331

def evaluate(expr)             = @client.evaluate(@name, expr)[:result]

#fill(selector = nil, value = nil, ref: nil) ⇒ Object



313
314
315
316
317
# File 'lib/browserctl/workflow.rb', line 313

def fill(selector = nil, value = nil, ref: nil)
  with_selector_fallback(:fill, selector, ref) do |sel, r|
    @client.fill(@name, sel, value, ref: r)
  end
end

#hover(selector = nil, ref: nil) ⇒ Object



343
344
345
346
347
# File 'lib/browserctl/workflow.rb', line 343

def hover(selector = nil, ref: nil)
  with_selector_fallback(:hover, selector, ref) do |sel, r|
    @client.hover(@name, sel, ref: r)
  end
end


311
# File 'lib/browserctl/workflow.rb', line 311

def navigate(url) = unwrap @client.navigate(@name, url)

#press(key) ⇒ Object



341
# File 'lib/browserctl/workflow.rb', line 341

def press(key) = unwrap @client.press(@name, key)

#screenshotObject



326
# File 'lib/browserctl/workflow.rb', line 326

def screenshot(**)            = unwrap @client.screenshot(@name, **)

#select(selector = nil, value = nil, ref: nil) ⇒ Object



355
356
357
358
359
# File 'lib/browserctl/workflow.rb', line 355

def select(selector = nil, value = nil, ref: nil)
  with_selector_fallback(:select, selector, ref) do |sel, r|
    @client.select(@name, sel, value, ref: r)
  end
end

#snapshotObject



325
# File 'lib/browserctl/workflow.rb', line 325

def snapshot(**)              = unwrap @client.snapshot(@name, **)

#storage_get(key, store: "local") ⇒ Object



333
334
335
# File 'lib/browserctl/workflow.rb', line 333

def storage_get(key, store: "local")
  @client.storage_get(@name, key, store: store)[:value]
end

#storage_set(key, value, store: "local") ⇒ Object



337
338
339
# File 'lib/browserctl/workflow.rb', line 337

def storage_set(key, value, store: "local")
  unwrap @client.storage_set(@name, key, value, store: store)
end

#upload(selector = nil, path = nil, ref: nil) ⇒ Object



349
350
351
352
353
# File 'lib/browserctl/workflow.rb', line 349

def upload(selector = nil, path = nil, ref: nil)
  with_selector_fallback(:upload, selector, ref) do |sel, r|
    @client.upload(@name, sel, path, ref: r)
  end
end

#urlObject



330
# File 'lib/browserctl/workflow.rb', line 330

def url                        = @client.url(@name)[:url]

#wait(sel, timeout: 30) ⇒ Object



327
# File 'lib/browserctl/workflow.rb', line 327

def wait(sel, timeout: 30)    = unwrap @client.wait(@name, sel, timeout: timeout)