Codeception / module-webdriver

WebDriver module for Codeception
MIT License
36 stars 25 forks source link

Example of `executeAsyncJs()` #130

Open SOHELAHMED7 opened 6 months ago

SOHELAHMED7 commented 6 months ago

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