class Playwright::JSHandle

‘method: Page.evaluateHandle`

methods.
JSHandle instances can be used as an argument in [‘method: Page.evalOnSelector`], [`method: Page.evaluate`] and
gets destroyed.
[`method: JSHandle.dispose`]. JSHandles are auto-disposed when their origin frame gets navigated or the parent context
JSHandle prevents the referenced JavaScript object being garbage collected unless the handle is exposed with
“`
# …
window_handle = page.evaluate_handle(“window”)
“`python sync
method.
JSHandle represents an in-page JavaScript object. JSHandles can be created with the [`method: Page.evaluateHandle`]

def as_element

Returns either `null` or the object handle itself, if the object handle is an instance of `ElementHandle`.
def as_element
  wrap_impl(@impl.as_element)
end

def dispose

The `jsHandle.dispose` method stops referencing the element handle.
def dispose
  wrap_impl(@impl.dispose)
end

def evaluate(expression, arg: nil)

```
assert tweet_handle.evaluate("node => node.innerText") == "10 retweets"
tweet_handle = page.query_selector(".tweet .retweets")
```python sync

**Usage**

its value.
If `expression` returns a [Promise], then `handle.evaluate` would wait for the promise to resolve and return

This method passes this handle as the first argument to `expression`.

Returns the return value of `expression`.
def evaluate(expression, arg: nil)
  wrap_impl(@impl.evaluate(unwrap_impl(expression), arg: unwrap_impl(arg)))
end

def evaluate_handle(expression, arg: nil)

See [`method: Page.evaluateHandle`] for more details.

for the promise to resolve and return its value.
If the function passed to the `jsHandle.evaluateHandle` returns a [Promise], then `jsHandle.evaluateHandle` would wait

The only difference between `jsHandle.evaluate` and `jsHandle.evaluateHandle` is that `jsHandle.evaluateHandle` returns `JSHandle`.

This method passes this handle as the first argument to `expression`.

Returns the return value of `expression` as a `JSHandle`.
def evaluate_handle(expression, arg: nil)
  wrap_impl(@impl.evaluate_handle(unwrap_impl(expression), arg: unwrap_impl(arg)))
end

def event_emitter_proxy

def event_emitter_proxy
_emitter_proxy ||= EventEmitterProxy.new(self, @impl)

def get_properties

```
handle.dispose()
document_handle = properties.get("document")
window_handle = properties.get("window")
properties = handle.get_properties()
handle = page.evaluate_handle("({ window, document })")
```python sync

**Usage**

The method returns a map with **own property names** as keys and JSHandle instances for the property values.
def get_properties
  wrap_impl(@impl.get_properties)
end

def get_property(propertyName)

Fetches a single property from the referenced object.
def get_property(propertyName)
  wrap_impl(@impl.get_property(unwrap_impl(propertyName)))
end

def json_value

object has circular references.
**NOTE**: The method will return an empty JSON object if the referenced object is not stringifiable. It will throw an error if the

Returns a JSON representation of the object. If the object has a `toJSON` function, it **will not be called**.
def json_value
  wrap_impl(@impl.json_value)
end

def off(event, callback)

@nodoc
-- inherited from EventEmitter --
def off(event, callback)
  event_emitter_proxy.off(event, callback)
end

def on(event, callback)

@nodoc
-- inherited from EventEmitter --
def on(event, callback)
  event_emitter_proxy.on(event, callback)
end

def once(event, callback)

@nodoc
-- inherited from EventEmitter --
def once(event, callback)
  event_emitter_proxy.once(event, callback)
end

def to_s

@nodoc
def to_s
  wrap_impl(@impl.to_s)
end