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.



359
360
361
362
363
364
# File 'lib/browserctl/workflow.rb', line 359

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.



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

def replay_context
  @replay_context
end

Instance Method Details

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



374
375
376
377
378
# File 'lib/browserctl/workflow.rb', line 374

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



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

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

#devtoolsObject



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

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

#dialog_accept(text: nil) ⇒ Object



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

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

#dialog_dismissObject



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

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

#evaluate(expr) ⇒ Object



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

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

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



368
369
370
371
372
# File 'lib/browserctl/workflow.rb', line 368

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



398
399
400
401
402
# File 'lib/browserctl/workflow.rb', line 398

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


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

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

#press(key) ⇒ Object



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

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

#screenshotObject



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

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

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



410
411
412
413
414
# File 'lib/browserctl/workflow.rb', line 410

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



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

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

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



388
389
390
# File 'lib/browserctl/workflow.rb', line 388

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

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



392
393
394
# File 'lib/browserctl/workflow.rb', line 392

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



404
405
406
407
408
# File 'lib/browserctl/workflow.rb', line 404

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



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

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

#wait(sel, timeout: 30) ⇒ Object



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

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