Class: Leash::Integration::PuppeteerClient
- Inherits:
-
Object
- Object
- Leash::Integration::PuppeteerClient
- Defined in:
- lib/leash/integration/puppeteer.rb
Instance Method Summary collapse
-
#initialize(leash) ⇒ PuppeteerClient
constructor
Create a new Puppeteer integration client.
-
#puppeteer_click(selector) ⇒ Object
Click an element on the page.
-
#puppeteer_evaluate(script) ⇒ Object
Execute JavaScript in the browser console.
-
#puppeteer_fill(selector, value) ⇒ Object
Fill out an input field.
-
#puppeteer_hover(selector) ⇒ Object
Hover an element on the page.
-
#puppeteer_navigate(url, launchoptions: nil, allowdangerous: nil) ⇒ Object
Navigate to a URL.
-
#puppeteer_screenshot(name, selector: nil, width: nil, height: nil, encoded: nil) ⇒ Object
Take a screenshot of the current page or a specific element.
-
#puppeteer_select(selector, value) ⇒ Object
Select an element on the page with Select tag.
Constructor Details
#initialize(leash) ⇒ PuppeteerClient
Create a new Puppeteer integration client.
11 12 13 |
# File 'lib/leash/integration/puppeteer.rb', line 11 def initialize(leash) @leash = leash end |
Instance Method Details
#puppeteer_click(selector) ⇒ Object
Click an element on the page
53 54 55 56 57 58 |
# File 'lib/leash/integration/puppeteer.rb', line 53 def puppeteer_click(selector) params = { 'selector' => selector }.compact @leash.call('puppeteer', 'puppeteer_click', params) end |
#puppeteer_evaluate(script) ⇒ Object
Execute JavaScript in the browser console
101 102 103 104 105 106 |
# File 'lib/leash/integration/puppeteer.rb', line 101 def puppeteer_evaluate(script) params = { 'script' => script }.compact @leash.call('puppeteer', 'puppeteer_evaluate', params) end |
#puppeteer_fill(selector, value) ⇒ Object
Fill out an input field
65 66 67 68 69 70 71 |
# File 'lib/leash/integration/puppeteer.rb', line 65 def puppeteer_fill(selector, value) params = { 'selector' => selector, 'value' => value }.compact @leash.call('puppeteer', 'puppeteer_fill', params) end |
#puppeteer_hover(selector) ⇒ Object
Hover an element on the page
90 91 92 93 94 95 |
# File 'lib/leash/integration/puppeteer.rb', line 90 def puppeteer_hover(selector) params = { 'selector' => selector }.compact @leash.call('puppeteer', 'puppeteer_hover', params) end |
#puppeteer_navigate(url, launchoptions: nil, allowdangerous: nil) ⇒ Object
Navigate to a URL
21 22 23 24 25 26 27 28 |
# File 'lib/leash/integration/puppeteer.rb', line 21 def puppeteer_navigate(url, launchoptions: nil, allowdangerous: nil) params = { 'url' => url, 'launchOptions' => , 'allowDangerous' => allowdangerous }.compact @leash.call('puppeteer', 'puppeteer_navigate', params) end |
#puppeteer_screenshot(name, selector: nil, width: nil, height: nil, encoded: nil) ⇒ Object
Take a screenshot of the current page or a specific element
38 39 40 41 42 43 44 45 46 47 |
# File 'lib/leash/integration/puppeteer.rb', line 38 def puppeteer_screenshot(name, selector: nil, width: nil, height: nil, encoded: nil) params = { 'name' => name, 'selector' => selector, 'width' => width, 'height' => height, 'encoded' => encoded }.compact @leash.call('puppeteer', 'puppeteer_screenshot', params) end |
#puppeteer_select(selector, value) ⇒ Object
Select an element on the page with Select tag
78 79 80 81 82 83 84 |
# File 'lib/leash/integration/puppeteer.rb', line 78 def puppeteer_select(selector, value) params = { 'selector' => selector, 'value' => value }.compact @leash.call('puppeteer', 'puppeteer_select', params) end |