Class: Playwright::JavaScript::Expression
- Inherits:
-
Object
- Object
- Playwright::JavaScript::Expression
- Defined in:
- lib/playwright/javascript/expression.rb
Instance Method Summary collapse
- #eval_on_selector(channel, selector, strict: nil) ⇒ Object
- #eval_on_selector_all(channel, selector) ⇒ Object
- #evaluate(channel) ⇒ Object
- #evaluate_handle(channel) ⇒ Object
-
#initialize(expression, arg) ⇒ Expression
constructor
A new instance of Expression.
- #wait_for_function(channel, polling:, timeout:) ⇒ Object
Constructor Details
#initialize(expression, arg) ⇒ Expression
Returns a new instance of Expression.
4 5 6 7 |
# File 'lib/playwright/javascript/expression.rb', line 4 def initialize(expression, arg) @expression = expression @serialized_arg = ValueSerializer.new(arg).serialize end |
Instance Method Details
#eval_on_selector(channel, selector, strict: nil) ⇒ Object
27 28 29 30 31 32 33 34 35 36 |
# File 'lib/playwright/javascript/expression.rb', line 27 def eval_on_selector(channel, selector, strict: nil) params = { selector: selector, expression: @expression, arg: @serialized_arg, } params[:strict] = strict if strict value = channel.('evalOnSelector', params) ValueParser.new(value).parse end |
#eval_on_selector_all(channel, selector) ⇒ Object
38 39 40 41 42 43 44 45 46 |
# File 'lib/playwright/javascript/expression.rb', line 38 def eval_on_selector_all(channel, selector) value = channel.( 'evalOnSelectorAll', selector: selector, expression: @expression, arg: @serialized_arg, ) ValueParser.new(value).parse end |
#evaluate(channel) ⇒ Object
9 10 11 12 13 14 15 16 |
# File 'lib/playwright/javascript/expression.rb', line 9 def evaluate(channel) value = channel.( 'evaluateExpression', expression: @expression, arg: @serialized_arg, ) ValueParser.new(value).parse end |
#evaluate_handle(channel) ⇒ Object
18 19 20 21 22 23 24 25 |
# File 'lib/playwright/javascript/expression.rb', line 18 def evaluate_handle(channel) resp = channel.( 'evaluateExpressionHandle', expression: @expression, arg: @serialized_arg, ) ::Playwright::ChannelOwner.from(resp) end |
#wait_for_function(channel, polling:, timeout:) ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/playwright/javascript/expression.rb', line 48 def wait_for_function(channel, polling:, timeout:) params = { expression: @expression, 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 |