Skip to content

Expect assertions break using before/after methods #549

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

Closed
munkyjunky opened this issue Jul 7, 2015 · 15 comments
Closed

Expect assertions break using before/after methods #549

munkyjunky opened this issue Jul 7, 2015 · 15 comments
Assignees
Labels

Comments

@munkyjunky
Copy link

Addition of the after method to my assertions causes an error to be thrown.

Code:

var homepage = browser.page.homepage();
var navigation = homepage.section.navigation;
/* *** snip *** */
homepage.expect.section('@navigation').to.be.visible.after(util.timeout);

Error:

An error occurred while running the tests:
TypeError: Cannot read property 'ELEMENT' of null
    at VisibleAssertion.executeCommand (C:\Workspace\Project\node_modules\nightwatch\lib\api\expect\visible.js:30:54)
    at VisibleAssertion.BaseAssertion.onPromiseResolved (C:\Workspace\Project\node_modules\nightwatch\lib\api\expect\_baseAssertion.js:104:8)
    at VisibleAssertion.retryCommand (C:\Workspace\Project\node_modules\nightwatch\lib\api\expect\visible.js:55:8)
    at Timer.listOnTimeout (timers.js:119:15)

Removing the after method prevents this error from occurring, however my test fails (as expected in that case, as the element is not visible). What I'm trying to achieve with my test:

  • load page
  • click an element
  • expect the navigation section to appear within 30s (the above code)
  • click an element within the navigation section

Changing the section declaration for just an element causes the same error. I suspect this error is happening as I'm expecting a section of a page to become visible that at the initial time of assertion is not on the page. Switching to browser.waitForElementVisible allows me to complete the test, so I think this is an issue within the expect API.

Can't post the full test due to this being a work project.

@beatfactor beatfactor added the bug label Jul 7, 2015
@beatfactor
Copy link
Member

Have you tried referencing the element by its css selector directly? Does that produce the same error?

@munkyjunky
Copy link
Author

The following works:
browser.waitForElementVisible('.list-container', util.timeout);

Keeping it within the expect / page api, however, still breaks it with the same error:
homepage.expect.element('.list-container').to.be.visible.after(util.timeout);

@sknopf sknopf self-assigned this Jul 7, 2015
@sknopf
Copy link
Collaborator

sknopf commented Jul 7, 2015

Thanks, I see the issue, will fix soon.

@sknopf
Copy link
Collaborator

sknopf commented Jul 8, 2015

Posted a fix here

@munkyjunky
Copy link
Author

I'm seeing this issue occurring again. Running nightwatch v0.9.0.

This test fails:

login_modal.expect.element('@modal').to.not.be.visible.before(browser.globals.timeout);
header_login.expect.element('@login_button').to.not.be.present;
header_login.expect.element('@logout_button').to.be.visible;

with output:
Expected element <.Login__modal> to not be visible in 10000ms - Expected "not visible" but got: "visible"

This test works:

browser.pause(browser.globals.timeout);
login_modal.expect.element('@modal').to.not.be.visible;
header_login.expect.element('@login_button').to.not.be.present;
header_login.expect.element('@logout_button').to.be.visible;

Trying CSS selectors instead of page objects makes no difference to this.

@beatfactor
Copy link
Member

Are you sure it's the same issue? There have been no changes in the area and your test doesn't seem to be doing exactly the same thing.

@munkyjunky
Copy link
Author

I previously raised this issue here #544, which was marked as a duplicate of this bug, so I thought it best to comment here. If you think it's a separate issue I can open a new issue instead?

Apologies, should have also referenced #544 in my previous comment.

@beatfactor
Copy link
Member

Btw, you can avoid .before(browser.globals.timeout); by setting the global waitForConditionTimeout, as it is done here.

@beatfactor
Copy link
Member

Have you changed anything in your setup? Like selenium or browser version?

On Thursday, 26 May 2016, Simon W [email protected] wrote:

I previously raised this issue here #544
#544, which was marked
as a duplicate of this bug, so I thought it best to comment here. If you
think it's a separate issue I can open a new issue instead?

Apologies, should have also referenced #544
#544 in my previous
comment.


You are receiving this because you commented.
Reply to this email directly or view it on GitHub
#549 (comment)

@munkyjunky
Copy link
Author

This is in a different project to my original issue, although I don't believe it was ever solved in that one either.

I'm running node v0.12.9, selenium server 2.53.0, and chrome webdriver from this package, v2.21.2. Also tested this under node 4.4.3, without change.

@beatfactor
Copy link
Member

And in nightwatch 0.8.18 it works as expected?

@beatfactor
Copy link
Member

Is it possible to see the verbose log output for the failing test in 0.9.0?

@munkyjunky
Copy link
Author

No, doesn't work in nightwatch 0.8,18 either. Since raising the issue originally I can't definitively tell you it has worked - this is for a work project and I swapped teams for a while so dropped the work we're doing with Nightwatch. I don't think this is something that has been broken in a recent release.

I've had to blank a few values in the output as this is client work and I'd rather avoid posting up their URLs, and also removed my login info. Output here: https://gist.github.com/munkyjunky/70d3105f9d1a86db6e3e07c106d2cc57

@beatfactor
Copy link
Member

Ok, from the output here is looks like the element is not visible so for some reason nightwatch is incorrectly reporting that it is. I'll look into it, can you open a separate issue please?

@munkyjunky
Copy link
Author

Opened new issue #997

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

No branches or pull requests

3 participants