在Java中处理多个用户输入
我有一个用户的多个输入,基于此,我编写了一些方法来执行一些操作 要处理用户输入,我必须使用if-else-if或switch-case。寻找更可行的解决方案,而不是使用多个if-else或switch案例 输入示例包括单选按钮、复选框和下拉列表。因此,我已经编写了一些方法来执行一些操作在Java中处理多个用户输入,java,selenium,Java,Selenium,我有一个用户的多个输入,基于此,我编写了一些方法来执行一些操作 要处理用户输入,我必须使用if-else-if或switch-case。寻找更可行的解决方案,而不是使用多个if-else或switch案例 输入示例包括单选按钮、复选框和下拉列表。因此,我已经编写了一些方法来执行一些操作 取而代之的是任何可行的解决方案。您可以创建一个抽象层。大概是这样的: public class TestInputs() { boolean radioButtonFoo1 boolea
取而代之的是任何可行的解决方案。您可以创建一个抽象层。大概是这样的:
public class TestInputs() {
boolean radioButtonFoo1
boolean checkBoxFoo2
public boolean getRadioButtonFoo1() {
return radioButtonFoo1
}
public boolean getCheckBoxFoo2() {
return checkBoxFoo2
}
public TestInputs(boolean radioButtonFoo1, boolean checkBoxFoo2) {
this.radioButtonFoo1 = radioButtonFoo1
this.checkBoxFoo2 = checkBoxFoo2
}
TestInputs testInputs = new TestInputs(true, false)
}
您的测试用例类可以扩展此TestInputs类,以便您可以直接调用测试数据:
if (testInputs.getRadioButtonFoo1 == true) {
// do something
}
提供一个[最小、完整且可验证的示例][1][1]:也许您正在寻找或?