Created
January 22, 2018 21:52
-
-
Save roydekleijn/80f8e424706b21c19d92cba8c1315557 to your computer and use it in GitHub Desktop.
Wrapper for interacting with selectbox elements in protractor.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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