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

No browser actions possible in callbacks #120

Closed
lxanders opened this issue Apr 3, 2014 · 6 comments
Closed

No browser actions possible in callbacks #120

lxanders opened this issue Apr 3, 2014 · 6 comments
Labels

Comments

@lxanders
Copy link

lxanders commented Apr 3, 2014

Yesterday I tried to do something like this (I simplified the example a little bit):

browser
    .waitForElementPresent('section div output', 5000)
    .getValue('section div output', function (result) {
        if (result.value !== 'someInterestingValue') {
            browser
                .click('a.linkToAnotherPage')
                .waitForElementVisible('td.withSomeInterestingClass a', 5000)
                .click('td.withSomeInterestingClass a');
        }
    });
    .doTheRestOfTheTest...

The reason for this was, that the part in the callback should only trigger when the condition passes (here read by using getValue and the value of its result).

It seems that this is not working because the click method didn't find the element. Here is an excerpt of the console output:

...
ERROR: Unable to locate element: "td.withSomeInterestingClass a" using: css selector
✔  Element <td.withSomeInterestingClass a> was visible after 3245 milliseconds.
Unable to locate element: "td.withSomeInterestingClass a" using: css selector
FAILED:  1 errors and 2 passed
...

So it seems, that the first click is done and successful (I confirmed that by watching the test run) and then some things happen in the wrong order. As the second click should be done after the waitForElementVisible and this part was successful, the click should work too. It seems the error message is caused by not finding the same element it was waiting for because it is called too early.

My ideas were:

  • First I thought the reason might be a problem with CSS selectors - reading the error message some times I don't think so anymore
  • Second thought: The context might be different in the callback - so I tried saving the browser-variable to another variable and calling this in the callback - didn't work - same error as above
  • There is a problem with the promises / asynchronity
@beatfactor
Copy link
Member

It's a bug alright, a problem with the queuing mechanism.

@beatfactor beatfactor added the bug label Apr 3, 2014
@erickbrower
Copy link

A coworker of mine ran into this very bug yesterday! He was trying to do browser nav in the getAttribute() callback

@kineticac
Copy link

@beatfactor Got this error as well. The order of items executing is no longer guaranteed after a callback is executed. I've tried nesting assertions within the callback as well, but those are also out of order. Seems like you have a handle on it?

@beatfactor
Copy link
Member

should be fixed.

@kineticac
Copy link

Works for me! Thanks for the quick fix!

@lxanders
Copy link
Author

lxanders commented Apr 4, 2014

Works for me, too. Thanks!

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

4 participants