附上我的下拉列表和文本框的图像示例我有一个下拉列表和一个文本框,我想创建一个 Pageobject 函数来解析 .css 或类 html 标识符并用“ - ”分割它,例如:
我有一个黄瓜.feature
文件可以做到这一点
And he filters account Name so that it contains dyno
所以在这里我说找到帐户名称列并在下拉列表中选择一个值,然后在文本框中输入一个值,理论上如果我让开发人员为下拉列表和文本框创建一个类似于此的 html 标识符: (特别是带有 accountName 的标识符)
<th _ngcontent-c2="" class="ui-p-6 ui-sortable-column"
preorderablecolumn="" style="text-align:left;"
ng-reflect-field="accountId" draggable="true">
Account Name
<p-sorticon _ngcontent-c2="" ng-reflect-field="accountId">
<span class="ui-sortable-column-icon fa fa-fw fa-sort"
ng-reflect-klass="ui-sortable-column-icon fa fa-"
ng-reflect-ng-class="[object Object]">
</span>
</p-sorticon>
</th>
这是我的步骤定义:
this.When(/^s?he filters (.*) so that it ?(.*)?(.*) ?(.*)$/,
(columnName: string, bySelectingTheFilter: string,
andEnteringText: string, intoTextBox: string) => {
return stage.theActorInTheSpotlight().attemptsTo(
FilterTheList.toShow(columnName, bySelectingTheFilter,
andEnteringText, intoTextBox)
);
});
我有一个任务文件,其中包含选择下拉列表并在此处的文本框中输入数据的类:
export class FilterTheList implements Task {
constructor(private columnName: string, private filter: string,
private text: string, private filterTextBox: string) {
}
static filterOptionShow() {
return Click.on(AccountListUI.accountListShowFilter);
}
static toShow(columnName: string, filter: string, text: string, filterTextBox: string){
// @todo need to sanitize columns to match HTML identifier
// this.columnName = columnName;
// @todo need to sanitize columns to match HTML identifier
// this.filterTextBox = filterTextBox;
return new FilterTheList(columnName, filter, text, filterTextBox);
}
@step('{0} filters the list to show #taskType items')
performAs(actor: PerformsTasks): PromiseLike<void> {
return actor.attemptsTo(
Select.theValue(this.filter)
.from(AccountListUI.filter.dropDown(this.columnName)),
Enter.theValue(this.text)
.into(AccountListUI.filter.textBox(this.filterTextBox))
);
}
}
我想我可以像这样制作一个pageoject函数
static filterItems = {
dropDown: (name: string) => Target.the(`filter dropdown called ${name}`)
.located(by.css(`th.${name} input[type="select"]`)),
textBox: (name: string) => Target.the(`filter textbox called ${name}`)
.located(by.css(`th.${name} input[type="text"]`)),
};
但是在我找到列名后将调用该函数
这就是我迷失了如何制作一个函数来说“嘿,从.feature
文件中获取列名并将其解析为 html 提供的内容(即:将帐户名称解析为帐户名称)