【发布时间】:2020-12-15 02:04:33
【问题描述】:
我必须针对两个 url 运行 test1.feature 文件。在其中一个 url 中,我有一个名为 EIN 的字段,但在第二个 url 中,相同的字段名为 ABN
我们如何使步骤定义动态化以处理第二个字符串中的任何文本。
网址 1:https://testsite.us.com/student
该字段被命名为“EIN”
网址 2:https://testsite.au.com/student
该字段被命名为“ABN”
test1.feature
And I type "11 234 234 444" in "ABN" field
step_definition
//在文本框输入框中输入文本值
Then('I type {string} in {string} field', (textval, textboxname) => {
switch (textboxname) {
case "Email":
case "Work Phone":
case "ABN":
case "EIN":
case "ACN":
cy.get('#profile_container').parent().find('.fieldHeaderClass').contains(textboxname)
.next().find('input')
.clear({force:true})
.type(textval, { force: true });
break;
//final else condition
default:
cy.get('#profile_container').parent().find('.fieldHeaderClass').contains(textboxname)
.next()
.type(textval, { force: true });
}
});
【问题讨论】:
标签: cypress cypress-cucumber-preprocessor