module-webdriver icon indicating copy to clipboard operation
module-webdriver copied to clipboard

Example of `executeAsyncJs()`

Open SOHELAHMED7 opened this issue 1 year ago • 0 comments

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

SOHELAHMED7 avatar May 14 '24 15:05 SOHELAHMED7