By.model not working with select elements
with a template such as the following:
<select ng-model="foo" value="bar">
<option value="bar">bar</option>
</select>
this test:
expect(element(by.model("foo")).getAttribute("value")).toEqual("bar");
will fail with the following error:
Error: JS locator script result was not a WebElement
where I would expect it to find the select element and the test to pass.
This appears to be a problem with select lists specifically, as similar tests will pass fine for non-select input elements.
This is an issue with any non input elements.
For by.model function definition see
https://github.com/angular/protractor/blob/master/lib/locators.js#L112
And for the actual selector creation https://github.com/angular/protractor/blob/master/lib/clientsidescripts.js#L228
What you want is element(by.select("foo"))
It seems to me that the by.model selector should select anything with a ng-model attribute, at least that is the expected behaviour. Could we change the selector in clientsidescripts from input[...] to *[...] ?
Yes, this should probably happen. I'm trying to think of any downsides - let me open a separate issue to get comments.
On Wed, Dec 4, 2013 at 12:00 PM, Max Brosnahan [email protected]:
It seems to me that the by.model selector should select anything with a ng-model attribute, at least that is the expected behaviour. Could we change the selector in clientsidescripts from input[...] to *[...] ?
— Reply to this email directly or view it on GitHubhttps://github.com/angular/protractor/issues/316#issuecomment-29839571 .
Please continue discussion in #321