execute method Null safety

Future execute(
  1. String script,
  2. List args
)

Inject a snippet of JavaScript into the page for execution in the context of the currently selected frame. The executed script is assumed to be synchronous and the result of evaluating the script is returned.

The script argument defines the script to execute in the form of a function body. The value returned by that function will be returned to the client. The function will be invoked with the provided args array and the values may be accessed via the arguments object in the order specified.

Arguments may be any JSON-able object. WebElements will be converted to the corresponding DOM element. Likewise, any DOM Elements in the script result will be converted to WebElements.

Implementation

Future<dynamic> execute(String script, List args) => _client.send(
      _handler.core.buildExecuteRequest(script, args),
      (response) => _handler.core.parseExecuteResponse(
        response,
        (elementId) => getElement(elementId, this, 'javascript'),
      ),
    );