量角器中没有这样的东西,但是我们可以编写自己的东西:
select-wrapper.js
'use strict';var SelectWrapper = function(selector) { this.webElement = element(selector);};SelectWrapper.prototype.getOptions = function() { return this.webElement.all(by.tagName('option'));};SelectWrapper.prototype.getSelectedOptions = function() { return this.webElement.all(by.css('option[selected="selected"]'));};SelectWrapper.prototype.selectByValue = function(value) { return this.webElement.all(by.css('option[value="' + value + '"]')).click();};SelectWrapper.prototype.selectByPartialText = function(text) { return this.webElement.all(by.cssContainingText('option', text)).click(); };SelectWrapper.prototype.selectByText = function(text) { return this.webElement.all(by.xpath('option[.="' + text + '"]')).click(); };module.exports = SelectWrapper;用法
var SelectWrapper = require('select-wrapper');var mySelect = new SelectWrapper(by.id('fruits'));# select an option by valuemySelect.selectByValue('1');# select by visible textmySelect.selectByText('Mango');请注意, Select
是Javascript中的保留字



