Class: Playwright::JavaScript::Function
- Inherits:
-
Object
- Object
- Playwright::JavaScript::Function
- Defined in:
- lib/playwright/javascript/function.rb
Instance Method Summary collapse
- #eval_on_selector(channel, selector) ⇒ Object
- #eval_on_selector_all(channel, selector) ⇒ Object
- #evaluate(channel) ⇒ Object
- #evaluate_handle(channel) ⇒ Object
-
#initialize(definition, arg) ⇒ Function
constructor
A new instance of Function.
- #wait_for_function(channel, polling:, timeout:) ⇒ Object
Constructor Details
#initialize(definition, arg) ⇒ Function
Returns a new instance of Function.
4 5 6 7 |
# File 'lib/playwright/javascript/function.rb', line 4 def initialize(definition, arg) @definition = definition @serialized_arg = ValueSerializer.new(arg).serialize end |
Instance Method Details
#eval_on_selector(channel, selector) ⇒ Object
29 30 31 32 33 34 35 36 37 38 |
# File 'lib/playwright/javascript/function.rb', line 29 def eval_on_selector(channel, selector) value = channel.( 'evalOnSelector', selector: selector, expression: @definition, isFunction: true, arg: @serialized_arg, ) ValueParser.new(value).parse end |
#eval_on_selector_all(channel, selector) ⇒ Object
40 41 42 43 44 45 46 47 48 49 |
# File 'lib/playwright/javascript/function.rb', line 40 def eval_on_selector_all(channel, selector) value = channel.( 'evalOnSelectorAll', selector: selector, expression: @definition, isFunction: true, arg: @serialized_arg, ) ValueParser.new(value).parse end |
#evaluate(channel) ⇒ Object
9 10 11 12 13 14 15 16 17 |
# File 'lib/playwright/javascript/function.rb', line 9 def evaluate(channel) value = channel.( 'evaluateExpression', expression: @definition, isFunction: true, arg: @serialized_arg, ) ValueParser.new(value).parse end |
#evaluate_handle(channel) ⇒ Object
19 20 21 22 23 24 25 26 27 |
# File 'lib/playwright/javascript/function.rb', line 19 def evaluate_handle(channel) resp = channel.( 'evaluateExpressionHandle', expression: @definition, isFunction: true, arg: @serialized_arg, ) ::Playwright::ChannelOwner.from(resp) end |
#wait_for_function(channel, polling:, timeout:) ⇒ Object
51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/playwright/javascript/function.rb', line 51 def wait_for_function(channel, polling:, timeout:) params = { expression: @definition, isFunction: true, arg: @serialized_arg, polling: polling, timeout: timeout, }.compact if polling.is_a?(Numeric) params[:pollingInterval] = polling end resp = channel.('waitForFunction', params) ChannelOwners::JSHandle.from(resp) end |