Created
December 30, 2014 11:57
-
-
Save e-oz/0c5d9dbd3131d602f367 to your computer and use it in GitHub Desktop.
Protractor helper function: Click option[index] of select element
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
/** | |
* Click option[index] of select element | |
* @param select | |
* @param index | |
* @returns {protractor.promise} | |
*/ | |
function clickOption(select, index) { | |
var deferred = protractor.promise.defer(); | |
select.click().then(function () { | |
var options = select.all(by.css('option')); | |
expect(options.count()).toBeGreaterThan(index); | |
expect(options.get(index).getText()).toBeDefined(); | |
options.get(index).click().then(function () { | |
select.click(); | |
browser.waitForAngular().then(deferred.fulfill, deferred.reject); | |
}, deferred.reject); | |
}, deferred.reject); | |
return deferred.promise; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Usage example: