0

Is there a way in nightwatch where if I click on a link, it shouldn't redirect me to the url of the link but instead stay on the current page and just update the browser url?

So if I have a link like:

<a href='/hello' />

And I click on the link above it should just change the url to /hello and stay on the current page.

I didn't find this feature in the docs anywhere.

  • That would work in a single page app with client-side routing. Is that what you are testing? – LexJacobs Dec 26 '18 at 22:37
  • Yes I have a server side rendered react application with react-router for my client side routing. –  Dec 26 '18 at 23:02
  • So what is happening when you test it? What are you expecting to happen? – LexJacobs Dec 26 '18 at 23:25
  • When I click on the link, the browser shouldn't navigate to the `/hello` page but instead should stay on the current page. I forgot to mention that the link within my single page application goes to another application. I ONLY want the url to update with the new link so I can test that the link destination is correctwithout the browser redirecting to the new page. –  Dec 27 '18 at 01:42
  • 1
    Does this help? https://stackoverflow.com/a/8560766/3044358 – LexJacobs Dec 28 '18 at 01:40
  • Yes that's exactly what I needed. But I am not sure how I can get access to the history object in the nightwatch code. –  Jan 02 '19 at 22:33

0 Answers0