ryx / testcafe-browser-provider-nightmare

Testcafe browser provider for the nightmare browser automation library
MIT License
26 stars 5 forks source link

localStorage is lost after navigateTo() action #5

Open mokone91 opened 7 years ago

mokone91 commented 7 years ago

Hi,

I use testcafe-browser-provider-nightmare for headless testing on staging env, and seems nightmare lose localStorage data when navigateTo() method is called.

My project use it to store auth token, so if i try to navigate somewhere using navigateTo - i get anonymous user.

Thanks!

noderat commented 7 years ago

Confirmed. This is also happening to me as well.

AndreyBelym commented 7 years ago

Hi, I also confirm the issue and I'm investingating it in the moment.

noderat commented 7 years ago

I think it's related to https://github.com/electron/electron/issues/1731 but it seems highly unusual that testcafe would be ending the nightmare session instead of just changing the URL.

AlexanderMoskovkin commented 7 years ago

We've found that Nightmare performs some modifications with native dialogs (including beforeUnload) in their preload.js script. It breaks TestCafe behavior in some cases. We will find a way to fix it

tuanquynet commented 7 years ago

I have also encountered this problem. My app need to store token into localStorage. But the localStorage is clear after navigate to other page.

tuanquynet commented 7 years ago

@AlexanderMoskovkin : have you fixed it?

AndreyBelym commented 7 years ago

I'm going to fix it in the next release (about 3-4 weeks likely).

tuanquynet commented 6 years ago

@AndreyBelym Have you fixed it? If you don't have time, you can give me the guideline to do it?

AndreyBelym commented 6 years ago

Hello @tuanquynet, unfortunately I haven't had time to work out this. It will be really awesome if you handle this.

The default preload script needs to be modified. Mocks on beforeunload, unload events and on alert, prompt, confirm functions must be deleted, TestCafe have it's own mock to deal with this events and functions. Then the customized script should be passed to Nightmare in the provider code.

tuanquynet commented 6 years ago

@AndreyBelym Ok, Let me try.

tuanquynet commented 6 years ago

@AlexanderMoskovkin Have you fixed it?

tuanquynet commented 6 years ago

@AndreyBelym, @AlexanderMoskovkin : I have figured out the root cause. The problem come from nightmare at this line https://github.com/segmentio/nightmare/blob/master/lib/preload.js#L13 It work for me if I comment out the block of code from line 13 to 18. I will ask author of nightmare if we can remove that block of code.

peererror commented 6 years ago

any fix for this issue