Ama*_*har 6 java intellij-idea getter-setter
我有一种情况,我想为我的领域定义各种行为.
class SomePage {
//...
@FindBy(id = "selectEthinicity")
private WebElement ethinicitySelect;
@FindBy(id = "someId")
private WebElement usernameInputField;
@FindBy(id = "buttonSubmit")
private WebElement submitButton;
public void selectEthnicity(String param) throws Exception {
new Select(ethnicitySelect).selectByVisibleText(param);
}
public void selectEthnicityByIndex(String param) throws Exception {
new Select(ethnicitySelect).selectByIndex(Integer.parseInt(param));
}
public int getSelectEthinicityNumberOfOptions() {
new Select(ethnicitySelect).getOptions().size();
}
public void waitForOptionOfSelectEthnicityToLoad() {
//logic to wait for an options of Ethinicity to load
}
public void selectEthnicity_Wait(String param) throws Exception {
//wait
//select Ethinicity
}
public void selectEthnicityByIndex_Wait(String param) throws Exception {
//wait and
//Select Ethnicity by einde
}
//custom method for input Field
public String getUsernameInputFieldValue() {
usernameInputField.getAttribute("value");
}
public void enterUsernameInputField(String param) {
usernameInputField.sendKeys(param);
}
//custom method for button
public void clickSubmitButton() throws PageValidationException {
submitButton.click();
}
//...
}
Run Code Online (Sandbox Code Playgroud)
这里我有一个SomePage类,它是一个由对象()组成的页面对象(使用页面工厂模式WebElement).
基于字段名称的后缀我需要创建多个方法.如果后缀是*Select该字段将具有可以对所有人类似的方法的数量select field.如果是后缀*Button,则会有一个所需的方法button field.
我可以生成基于的自定义方法suffix of field names.
注意:IntelliJ支持修改自定义Getter和Setter,但它不允许每个字段使用多个方法.它限制为每个字段1个Getter和1个Setter.根据示例并非总是如此.我有一个场的多个二传手(一种二传手)或吸气剂.
在 IntelliJ IDEA 中生成 Getter 和 Setter:
| 归档时间: |
|
| 查看次数: |
1014 次 |
| 最近记录: |