在我的自动化框架中,我有5个不同的用户使用不同的密码。用户名和密码存储在yaml文件中,我们在必要时调用它们。我想编写通用登录场景,这样当我传递用户名时,测试应该针对该特定角色运行。例如,它可以针对dev env user、qa env user或uat env user。这是我写的,但我不知道我错在哪里?
...
StepHelper.setElement(Login_FIELD).waitUntilVisible().inputToElement(step.getValue(userName.name())); // It will get the specific username and types that on apps login field
String userName = "User1"; // This should be equal to the return value of above line of code
switch (userName) {
case User1: StepHelper.setElement(PASSWORD_FIELD).waitUntilVisible().inputToElement(step.getValue("P0"));
break;
case User2:
StepHelper.setElement(PASSWORD_FIELD).waitUntilVisible().inputToElement(step.getValue("P1"));
break;
case User3:
StepHelper.setElement(PASSWORD_FIELD).waitUntilVisible().inputToElement(step.getValue("P2"));
break;
case User4:
StepHelper.setElement(PASSWORD_FIELD).waitUntilVisible().inputToElement(step.getValue("P3"));
break;
case User5:
StepHelper.setElement(PASSWORD_FIELD).waitUntilVisible().inputToElement(step.getValue("P4"));
break;
default:
System.out.println("No matching username has been found");
}
暂无答案!
目前还没有任何答案,快来回答吧!