converter/e2e/app.po.ts

45 lines
1.3 KiB
TypeScript
Raw Normal View History

2017-07-25 23:40:19 +02:00
import {browser, by, element, ElementFinder} from 'protractor';
import {promise, WebElementPromise} from 'selenium-webdriver';
2017-04-15 14:47:43 +02:00
export class ConvertorizrPage {
2017-07-25 23:40:19 +02:00
navigateTo(): promise.Promise<any> {
return browser.get('/');
}
2017-07-25 23:40:19 +02:00
private getInputField(index: number): WebElementPromise {
return element
.all(by.css('app-root div.inputwrapper'))
.get(index)
.element(by.css('.textwrapper textarea'))
.getWebElement();
2017-04-15 13:50:10 +02:00
}
2017-07-25 23:40:19 +02:00
getInputFieldContent(index: number): promise.Promise<string> {
return this.getInputField(index).getText();
}
setInputFieldContent(index: number, content: string): promise.Promise<void> {
return this.getInputField(index).sendKeys(content);
}
private getConverterDropdown(index: number): ElementFinder {
return element
.all(by.css('app-root div.inputwrapper'))
.get(index)
.element(by.css('.selectwrapper select'));
}
getSelectedConverterOption(index: number): promise.Promise<string> {
return this.getConverterDropdown(index)
.$('option:checked')
.getWebElement()
.getText();
}
selectConverterOption(index: number, optionName: string): promise.Promise<void> {
return this.getConverterDropdown(index)
.element(by.cssContainingText('option', optionName))
.click();
}
}