browser-monkey
Advanced tools
Comparing version 1.15.10 to 1.15.11
@@ -1,2 +0,1 @@ | ||
module.exports = function dispatchEvent(el, type){ | ||
@@ -3,0 +2,0 @@ var e; |
24
index.js
@@ -458,20 +458,9 @@ var retry = require('trytryagain'); | ||
return this.element(options).then(function(element) { | ||
var selectedOption; | ||
var optionList = element.options; | ||
for (var optionIndex = 0; optionIndex < optionList.length; optionIndex++){ | ||
if (optionList[optionIndex].text.indexOf(selectOptions.text) !== -1){ | ||
selectedOption = optionList[optionIndex]; | ||
selectedOption.selected = true; | ||
return this.find('option', {text: selectOptions.text}).element().then(function(optionElement) { | ||
optionElement.selected = true; | ||
var selectElement = optionElement.parentNode; | ||
debug('select', element); | ||
blurActiveElement(); | ||
dispatchEvent(element, 'change'); | ||
break; | ||
} | ||
} | ||
if (!selectedOption){ | ||
throw new Error('No option found for "'+selectOptions.text+'" in select.'); | ||
} | ||
debug('select', selectElement); | ||
blurActiveElement(); | ||
dispatchEvent(selectElement, 'change'); | ||
}); | ||
@@ -484,3 +473,2 @@ }; | ||
blurActiveElement(); | ||
return sendkeys(element, text); | ||
@@ -487,0 +475,0 @@ }); |
{ | ||
"name": "browser-monkey", | ||
"version": "1.15.10", | ||
"version": "1.15.11", | ||
"description": "reliable dom testing", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -238,2 +238,20 @@ require('lie/polyfill'); | ||
it('should select an option that eventually appears', function(){ | ||
var promise = browser.find('.element').select({text: 'Second'}); | ||
var selectedItem = undefined; | ||
var select = $('<select class="element"></select>').appendTo(div).change(function (e) { | ||
var el = e.target; | ||
selectedItem = el.options[el.selectedIndex].text; | ||
}); | ||
setTimeout(function () { | ||
$('<option>First</option><option>Second</option>').appendTo(select); | ||
}, 20); | ||
return promise.then(function () { | ||
expect(selectedItem).to.equal('Second'); | ||
}); | ||
}); | ||
it('should error when the specified option does not exist', function(){ | ||
@@ -313,12 +331,11 @@ var promise = browser.find('.element').select({text: 'Does not exist'}); | ||
$(div).find('.input') | ||
.on('blur', function(){ | ||
firedEvents.push('blur'); | ||
}).on('change', function(){ | ||
firedEvents.push('change'); | ||
}) | ||
$(div).find('.input').one('blur', function(e){ | ||
firedEvents.push('blur'); | ||
}).one('change', function(){ | ||
firedEvents.push('change'); | ||
}); | ||
return browser.find('.input').typeIn('first').then(function(){ | ||
return browser.find('.change').typeIn('second'); | ||
}).then(function(){ | ||
}).then(function () { | ||
expect(firedEvents).to.eql([ | ||
@@ -325,0 +342,0 @@ 'change', |
54906
1156