Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not able to access the url of a page #1884

Closed
MonalisaSahoo opened this issue Sep 15, 2018 · 13 comments

Comments

@MonalisaSahoo
Copy link

commented Sep 15, 2018

I have not been able to get the url during the test runs intermittently.
Let me give you the background: On clicking of a button on a page it navigates to the next page. Upon navigation first thing I would like to validate the url during my test.
Below is the snippet of code I have been using to fetch the url from the current page.
#1. Native implementation of nightwatch for the url assertion

    assertUrlContains(text) {
      this.assert.urlContains(text);
      return this;
    }

#2. Also, tried to fetch the url using the api.url with promise pattern.

getCurrentUrl() {
      return new Promise((resolve) => {
        this.api.url((result) => {
          resolve(result.value);
        });
      });
    }

Both of the approach have same issues and below is the stacktrace of the error:

SEARCH RESULTS URL: null
(node:12375) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): TypeError: Cannot read property 'indexOf' of null
(node:12375) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
✖ TypeError: Cannot read property 'indexOf' of null 

Something strange I've noticed that the browser navigate to the target page but the nightwatch unable to get the url even though the page load event completes.

@ghost

This comment has been minimized.

Copy link

commented Sep 24, 2018

Share your code to gist and link here please

@aberonni

This comment has been minimized.

Copy link
Collaborator

commented Sep 26, 2018

@MonalisaSahoo I'm using this repo to reproduce various bug reports: https://github.com/aberonni/nightwatch-bug-report

If it makes it easier for you, you could consider adding an example there

@MonalisaSahoo

This comment has been minimized.

Copy link
Author

commented Sep 27, 2018

Thanks @aberonni. Sure will add the details.

@monalisasahoo19

This comment has been minimized.

Copy link

commented Oct 7, 2018

Hi @aberonni, I couldn't able to push to this repo, so I made a fork from the current repo. Please checkout the issue here.
https://github.com/monalisasahoo19/nightwatch-bug-report-1

@MonalisaSahoo

This comment has been minimized.

Copy link
Author

commented Oct 11, 2018

Hi @Euphee and @aberonni, have you got any chance to look into the above issue?

@ghost

This comment has been minimized.

Copy link

commented Oct 11, 2018

@MonalisaSahoo yeap.I will try to help u

@ghost

This comment has been minimized.

Copy link

commented Oct 11, 2018

@MonalisaSahoo your test pass as correct.Сan you give me the text you are trying to compare your page url?

@MonalisaSahoo

This comment has been minimized.

Copy link
Author

commented Oct 14, 2018

Hi @Euphee , Thank you for looking into the issue.
It is an intermittent issue, if you run few times then can able to reproduce. But this is always reproducible if we run concurrently.
Finding the text is not the issue, the problem is getUrl returns me as NULL with the following error.

POST  /session/a9c14ed82905126a648426a2270eb977/element/0.14010346177366007-4/click - ECONNRESET
Error: socket hang up
    at createHangUpError (_http_client.js:331:15)
    at Socket.socketCloseListener (_http_client.js:363:23)
 Error while running .clickElement() protocol action: An unknown error has occurred.

   An error occurred while running .click() command on <Element [name=@searchButton]>: {"status":-1,"state":"","value":null,"errorStatus":"","error":"An unknown error has occurred."}

FYI - This seems the browser is getting hanged, in the following places the value returns as NULL.

  1. https://github.com/monalisasahoo19/nightwatch-bug-report-1/blob/9c71cc55868f86d320463ff5e2a4935678b4def6/tests/1884/page-objects/myPage.js#L30
  2. https://github.com/monalisasahoo19/nightwatch-bug-report-1/blob/9c71cc55868f86d320463ff5e2a4935678b4def6/tests/1884/page-objects/myPage.js#L10
@ghost

This comment has been minimized.

Copy link

commented Oct 15, 2018

@MonalisaSahoo add this to your nightwatch config file
test_workers: { enabled: true, workers: 'auto' }

@monalisasahoo19

This comment has been minimized.

Copy link

commented Oct 15, 2018

@Euphee , I already have those in my real project in the nightwatch.json but it's not in the sample it's been included .

Could you please try to run the few more times if you can able to reproduce the issue at least once.

@monalisasahoo19

This comment has been minimized.

Copy link

commented Oct 17, 2018

Hi @kemvrn, I have added one more test to reproduce the issue quite often. And also have added testResult.gif video to see the error.
I am really struggling with the issue. Would really appreciate your help. Please let me know if you need any further info.

@MonalisaSahoo

This comment has been minimized.

Copy link
Author

commented Oct 25, 2018

Hi @kemvrn / @aberonni, Could anyone of you please look into the issue. It is happening quite often in my execution.

@beatfactor

This comment has been minimized.

Copy link
Member

commented Nov 12, 2018

I'm closing this since I don't see a direct issue in nightwatch. Please open a new issue if you have more info.

@beatfactor beatfactor closed this Nov 12, 2018
@nightwatchjs nightwatchjs locked and limited conversation to collaborators Nov 12, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
4 participants
You can’t perform that action at this time.