Wednesday 15 January 2014

javascript - Protractor waiting for sendKeys() -



javascript - Protractor waiting for sendKeys() -

in web form built using angularjs, i'm trying come in info combo box, select value pressing downwards arrow key , come in key. after that, i'm checking combo box's popup window (it's kendo ui combo box) no longer visible.

the tests run in chrome on windows , mac os x. on windows, next code works fine:

comboinput.sendkeys('can') .sendkeys(protractor.key.enter) .sendkeys(protractor.key.arrow_down) .sendkeys(protractor.key.enter); expect(input.getattribute('value')).tobe('id_3'); expect(popup.getattribute('style')).tocontain('display: none');

protractor enters "can" combobox, selects visible entry using downwards arrow key, , confirms selection using come in key, dismisses combo box popup.

on os x, doesn't work, sec expectation fails, since come in key event dismiss popup isn't fired before evaluating expectation reason.

i found have alter code next create work:

comboinput.sendkeys('can') .sendkeys(protractor.key.enter) .sendkeys(protractor.key.arrow_down) .sendkeys(protractor.key.enter).then(function() { expect(input.getattribute('value')).tobe('id_3'); expect(popup.getattribute('style')).tocontain('display: none'); });

sendkeys returns promise, , if set expectation in there, works fine.

is right way this? none of examples found on web utilize then phone call on sendkeys.

and why first code work on windows , not on os x? missing something? there improve way this?

edit: perchance related handling of native keyboard events on os x? protractor documentation @ http://angular.github.io/protractor/#/api?view=webdriver.webelement.prototype.sendkeys has following:

note: on browsers native keyboard events not yet supported (e.g. firefox on os x), key events synthesized. special punctionation keys synthesized according standard qwerty en-us keyboard layout.

since sendkeys returns promise, it's asynchronous (as know) , liable happen later expected on machine. suspect if ran test 1000 times on windows, fail @ to the lowest degree few times same reason.

i've died of old age trying find "best practice" cases this, , don't think there one, other you're doing. many of protractor tests rely on promise-returning actions end beingness long strings of then() statements anonymous functions inside. see link:

how assign count of rows or gettext variable in protractor

basically, if don't forcefulness protractor things in right order, 5 times out of 10 happen in wrong order.

javascript angularjs protractor

No comments:

Post a Comment