Skip to content
This repository has been archived by the owner on Oct 28, 2024. It is now read-only.

WaitForFirstXHR doesn't work #21

Open
DmytroShtanko1 opened this issue Feb 22, 2018 · 3 comments
Open

WaitForFirstXHR doesn't work #21

DmytroShtanko1 opened this issue Feb 22, 2018 · 3 comments

Comments

@DmytroShtanko1
Copy link

DmytroShtanko1 commented Feb 22, 2018

Hello!

My code

            Then(/^XHR$/,  async () => {

              await client.waitForFirstXHR('POST', 50000,
                 function browserTrigger() {
                   client.click('@CreateButton'); //works
                }, function assertValues(xhrs) {
               console.log(xhrs);
              });
            });

well, this function doesn't listen any response.
and I get " Timed out waiting for POST XHR ! - Expected "XHR Request" but got: "Timed out""

@hughgr
Copy link

hughgr commented Mar 23, 2018

same error here

@dev-johnny-gh
Copy link

dev-johnny-gh commented Jan 23, 2019

@DmytroShtanko1, @hughgr I think this cause by browser refresh after your request sent, it cache the request result at window.xhrListen object, but while browser refresh or redirect, it's gone. So it can't get any result until timeout.

So, I create a fork version call nightwatch-xhr-local-storage and store the request result at localStorage to solve this issue.

@JalilArfaoui
Copy link
Collaborator

That's a nice idea @duxiaofeng-github !

We'd be happy to merge your changes here if you want to make a PR so that we can keep one single module ?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants