Skip to content

Example of executeAsyncJs() #130

@SOHELAHMED7

Description

@SOHELAHMED7

I have a case in which I request a API call via fetch/XHR (in execute async js method) grab its response and want to check that its response contains specific string.

Example:

$response = $I->executeAsyncJS(<<<JS
    do fetch call/API call/XHR
    wait for its response     return its response as string to PHP var $response
JS
);
$I->assertContains('needle', $response);

I have made several attempts but unable to achieve the desired result. Sometimes I get errors or sometime empty array []

It would be glad if such example is provided.

Note that there is also a unanswered question on Stack Overflow

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions