Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

RequestLogger not intercepting all http requests

I am trying to test this page http://prebid.org/ I want to know that image http://vcdn.adnxs.com/p/creative-image/27/c0/52/67/27c05267-5a6d-4874-834e-18e218493c32.png is loaded or not.

Hence i created a logger and checking the count of logger but it does not record this request.

I created custom logger and still it did not log. I am assuming that it only intercepts requests whose initiator is the page itself. So if any request initiated by third party js than it will not be recorded.

Any way i can implement this ?

like image 657
Jaimin Avatar asked Apr 02 '26 14:04

Jaimin


1 Answers

TestCafe is based on the testcafe-hammerhead proxy.

All requests go through this proxy, which leads to a delay in loading pages. http://prebid.org/ uses timeouts for "Adserver"/"bids", so at the first load, we see the "All Bidders Took Too Long or No Bid" server response.

Clicking on the "Refresh this ad" button helps to get around this problem, since repeated requests will be much faster.

test-prebid.js:

import { Selector, RequestLogger } from 'testcafe';

const logger     = RequestLogger('http://vcdn.adnxs.com/p/creative-image/27/c0/52/67/27c05267-5a6d-4874-834e-18e218493c32.png');
const refreshBtn = Selector('a').withText('Refresh this ad');

fixture('Prebid')
    .page(`http://prebid.org/`);

test
    .requestHooks(logger)
    (`image loading`, async (t) => {
        await t
            .click(refreshBtn)
            .expect(logger.contains(record => record.response.statusCode === 200)).ok();
    });

Test result:

> d:\Prebid>testcafe chrome,edge,ie test-prebid.js -e

Using locally installed version of TestCafe.
 Running tests in:
 - Chrome 69.0.3497 / Windows 10.0.0
 - Edge 17.17134.0 / Windows 10.0.0
 - IE 11.0.0 / Windows 10.0.0

 Prebid
 √ image loading

 1 passed (11s)

Note: http://devexpress.github.io/testcafe/documentation/using-testcafe/command-line-interface.html#-e---skip-js-errors

like image 176
Vladimir A. Avatar answered Apr 08 '26 14:04

Vladimir A.



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!