1

Is there any way of making this work ?

    $I->amOnPage('/');

    $I->wait(2);

    $I->executeJS('
        var theCookies = document.cookie.split(\';\');
        var aString = \'\';
        for (var i = 1 ; i <= theCookies.length; i++) {
            aString += i + \' \' + theCookies[i-1] + "\n";
        }
        return aString;
    ');

Besides the fact that I get an error thrown, would something like this be possible?

2
  • 1
    try $I->executeJS('return document.cookie.split(\';\')') Commented Nov 20, 2019 at 11:47
  • @Murthi Hey this actually works, but it does not show me any 3rd party cookies, ot at least not everything that i can see in the browser Commented Nov 20, 2019 at 11:56

1 Answer 1

2

It's documented here: https://codeception.com/docs/modules/WebDriver

executeJS

Executes custom JavaScript.

This example uses jQuery to get a value and assigns that value to a PHP variable:

$myVar = $I->executeJS('return $("#myField").val()');

// additional arguments can be passed as array
// Example shows `Hello World` alert:
$I->executeJS("window.alert(arguments[0])", ['Hello world']);
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.