// Execute JS $session->executeScript('document.body.firstChild.innerHTML = "";'); // evaluate JS expression: echo $session->evaluateScript( "return 'something from browser';" );
The difference between these methods is that
Session::evaluateScript returns the result of the expression. When you don’t need to get a return value, using
Session::executeScript is better.
You can also wait until a given JS expression returns a truthy value or the timeout is reached:
// wait for n milliseconds or // till JS expression becomes truthy: $session->wait( 5000, "$('.suggestions-results').children().length" );
Session::wait method returns
true when the evaluation becomes truthy. It will return
false when the timeout is reached.
Need to look into this code for other purposes
The second argument to
modal becomes visible. In your browser's console, try running
$('.modal:visible').length. Because the modal is open, that returns one. Now close it: it returns zero. Pass this as the second argument to
|"$('.modal:visible').length > 0"|
Run it again: