waitForRequest doesn't capture request quick enough
See original GitHub issueI use puppeteer for running click tests on a web application. A couple of test cases require me to find out whether or not a network request is sent to fetch a file from server. To do this I use puppeteer’s waitForRequest method.
However the requests aren’t captured consistently. On multiple occasions the command times out which results in a failed test. The chrome dev tools on the other hand capture the request while the test is running.
In verbose mode I get this feedback in console
I wait for request "http://localhost:4200/assets/img/cursor/zoom-in.cur"
[1] Error | TimeoutError: Timeout exceeded while waiting for event
Emitted | step.failed (I wait for request "http://localhost:4200/assets/img/cursor/zoom-in.cur")
Emitted | step.finish (I wait for request "http://localhost:4200/assets/img/cursor/zoom-in.cur")
[1] Error | TimeoutError: Timeout exceeded while waiting for event
This is the test scenario
I.click('.zoom');
I.waitForRequest("http://localhost:4200/assets/img/cursor/zoom-in.cur")
I.seeElement(".zoom-menu");
Details
- CodeceptJS version: 2.02
- NodeJS Version: 9.11.2
- Operating System: Windows 10 (1809)
- Configuration file:
exports.config = {
tests: './codecept-tests/*.js',
timeout: 10000,
output: './output',
helpers:
{
Puppeteer:
{
url: 'http://localhost',
show: true,
windowSize: '1280x720',
chrome:
{
defaultViewport: { width: 1280, height: 720 }
}
}
},
include: {},
bootstrap: false,
mocha: {},
name: 'frontend',
plugins: { screenshotOnFail: { enabled: true } }
}
Issue Analytics
- State:
- Created 5 years ago
- Reactions:6
- Comments:8
Top Results From Across the Web
waitForRequest doesn't capture request quick enough #1464
To do this I use puppeteer's waitForRequest method. However the requests aren't captured consistently. On multiple occasions the command times ...
Read more >waitForRequest doesn't capture request quick enough
I use puppeteer for running click tests on a web application. A couple of test cases require me to find out whether or...
Read more >Codeceptjs + Puppeteer. How to catch fast requests - Medium
My problem was that waitForRequest doesn't capture the request quick enough and my test always fails when I click the button and am...
Read more >Python Requests: Don't wait for request to finish - Stack Overflow
Here's a hacky way to do it: try: requests.get("http://127.0.0.1:8000/test/",timeout=0.0000000001) except requests.exceptions.ReadTimeout: pass.
Read more >Browser - MarketSquare
Browser library is a browser automation library for Robot Framework. This is the keyword documentation for Browser library.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
fwiw I do like:
In my case, the problem was that the Application was firing the Request before the waitForRequest took place. So it never catched the Request.
That is because Puppeteer waits 100ms (by Default) after actions like click, doubleClick or PressKey.
Puppeteer Config waitForAction
To solve the issue, I just had to set this waitForAction parameter to 0: