Skip to content

Instantly share code, notes, and snippets.

@roydekleijn
Created January 22, 2018 21:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save roydekleijn/80f8e424706b21c19d92cba8c1315557 to your computer and use it in GitHub Desktop.
Save roydekleijn/80f8e424706b21c19d92cba8c1315557 to your computer and use it in GitHub Desktop.
Wrapper for interacting with selectbox elements in protractor.
import {by, element} from 'protractor';
export class SelectWrapper {
select: any;
constructor(select: any) {
this.select = element(select);
}
getOptions() {
return this.select.all(by.tagName('option'));
}
getSelectedOptions() {
return this.select.all(by.css('option[selected="selected"]'));
}
selectByValue(value: string) {
this.select.all(by.css('option[value="' + value + '"]')).click();
}
selectByPartialText(text: string) {
this.select.all(by.cssContainingText('option', text)).click();
}
selectByText(text: string) {
this.select.all(by.xpath('option[.="' + text + '"]')).click();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment