I am trying to verify that correct option is selected from selectbox using protractor.
This is how I pick value from selectbox:
element(by.id('form-mileage-unit')).click().then(function() {
element(by.cssContainingText('option', browser.params.lengthUnit)).click();
});;
So base on this I write code below:
it('Verify paint color', function() {
element(by.id('form-mileage-unit')).click().then(function() {
element(by.cssContainingText('option', browser.params.lengthUnit).getAttribute("value")).toEqual(browser.params.lengthUnit);
});;
});
Unfortunately I am getting error:
TypeError: Object by.cssContainingText("option", "Motohodin") has no method 'getText'
Can someone advise me with this?
You are closing the parenthesis in the wrong place and there is no
expect()
. Replace:with:
If you are dealing with
select->option
constructions a lot, consider using an abstraction over it that would make your tests cleaner and more readable, see: