protractor icon indicating copy to clipboard operation
protractor copied to clipboard

Strange issue with getText()

Open abhishekswain opened this issue 11 years ago • 3 comments

Environment: Windows 7 (64bit) Jasmine2 Protractor 2.2.0

Details: In the below example issue is with the element(something..).click(); line of code , which executes and clicks successfully for the 1st example for fails for the 2nd example , where getText() is implemented in slightly different way.

element(something..).click();
**
**
**
expect(el.getText()).toBe('Hello, World!');

This works , that means the above command (element(something..).click()) works.

BUT:

element(something..).click();
**
**
**
el.getText().then(function(text) {
  expect(text).toBe('Hello, World!');
});

This doesn't work. That means the above command (element(something..).click()) does not work.

This is no error on console for the click event, but expectation fails as it depends on an element that appears after click.

We are wondering what these way of writing expectations to do with a previous click command. Although I understand environment over here with Node is asynchronous and controlFlow makes things to work in synchronous way.

Still this behaviour is very strange. Might be something related to jasmine2.

abhishekswain avatar Sep 21 '15 13:09 abhishekswain

I believe this is due to some confusion control flow issues with WebDriverJS, as documented here: https://github.com/SeleniumHQ/selenium/issues/677

We're working to clarify these issues and find a wider solution to solve problems like this - it's tricky because it depends on the context of the control flow a lot. The issue is rare, and we've only seen it show up if you're doing something more complicated like issuing these commands within a loop.

Could you try reducing your test to the simplest case, and see if this is still a problem?

juliemr avatar Sep 23 '15 18:09 juliemr

Thank you for the pointer. It was happening because of some explicit waits and improper use of ignoreSynchronization flag. It got sorted now :)

abhishekswain avatar Sep 24 '15 07:09 abhishekswain

Closing the issue, as it has been sorted out.

abhishekswain avatar Sep 24 '15 07:09 abhishekswain