Created
March 13, 2016 15:57
-
-
Save Xotabu4/e84ef362d2d7abbbefde to your computer and use it in GitHub Desktop.
Custom jasmine matchers with waiting
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| describe('Protractor Experiments', function () { | |
| beforeEach(function () { | |
| var customMatchers = { | |
| toAppear: function () { | |
| return { | |
| compare: function(actual, expected) { | |
| return { | |
| pass: actual.ptor_.wait(protractor.ExpectedConditions.visibilityOf(actual), 2000) | |
| .thenCatch((err) => false), | |
| message: 'OLOLO FAILED! ' + actual.parentElementArrayFinder.locator_.toString() | |
| } | |
| } | |
| }; | |
| }, | |
| toDissapear: function () { | |
| return { | |
| compare: function(actual, expected) { | |
| return { | |
| pass: actual.ptor_.wait(protractor.ExpectedConditions.invisibilityOf(actual), 5000).then(undefined, err=> false), | |
| message: 'OLOLO FAILED! ' + actual.parentElementArrayFinder.locator_.toString() | |
| }; | |
| } | |
| }; | |
| } | |
| }; | |
| jasmine.addMatchers(customMatchers); | |
| }); | |
| fit('creating custom jasmine matcher function with wait', function () { | |
| browser.get('http://www.protractortest.org/testapp/ng1/#/form'); | |
| //expect($('body')).toAppear(); | |
| let nonexit = $('nonexist'); | |
| //Тут весь фокус - нужно передавать промис а не ElementFinder :) | |
| expect(protractor.promise.fulfilled(nonexit)).toAppear(); | |
| expect(protractor.promise.fulfilled(nonexit)).toAppear(); | |
| }); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment