Skip to content

Conversation

@dunglas
Copy link
Member

@dunglas dunglas commented Sep 26, 2018

Allows to execute some JS in the context of the current page with $client->executeScript() and $client->executeAsyncScript():

Example:

// sync
$text = $client->executeScript('return document.querySelector(arguments[0]).innerText;', ['.myclass']);

// async
$text = $client->executeAsyncScript(<<<JS
setTimeout(function (parentArgs) {
    const callback = parentArgs[parentArgs.length - 1];
    const t = document.querySelector(parentArgs[0]).innerText;
    callback(t);
}, 100, arguments);
JS
    , ['.myclass']);

@dunglas dunglas merged commit d67f9db into symfony:master Sep 26, 2018
@dunglas dunglas deleted the js branch September 26, 2018 10:35
dunglas added a commit that referenced this pull request Dec 28, 2020
Add JS execution capabilities to Client
nicolas-grekas pushed a commit that referenced this pull request Jan 18, 2021
Add JS execution capabilities to Client
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant