我目前将我的元素位置存储在一个单独的类中,远离它们的访问器方法,并且我正在寻找一种更有效的存储它们的方法。从我读到的枚举中,如果要走的路。我的问题是我的假设是否正确?以及如何实施?以下是它现在如何工作的一个小例子:
元素类:
public class GeneralJobElements {
protected By ProcurementWorkFlow = By.name("procurementWorkflow");
protected By JobOwner = By.name("jobOwner");
protected By JobTitle = By.name("i18n_jobTitle_minimized");
}
访问器类:
public class CreateJobGeneralTabActions extends GeneralJobElements {
public CreateJobGeneralTabActions selectJobOwner(int index) {
logMessage(JobOwner, "Job Owner");
Select sele = new Select(getWebElement(JobOwner));
sele.selectByIndex(index);
return this;
}
公共 CreateJobGeneralTabActions fillJobTitle() {
logMessage(JobTitle, "Job Title");
getWebElement(JobTitle).sendKeys(JOB_TITLE);
logger.info("The job title is: " + JOB_TITLE);
return this;
}
public CreateJobGeneralTabActions selectJobApprovalWF(int index) {
logMessage(ProcurementWorkFlow, "Procurement Workflow");
Select sele = new Select(getWebElement(ProcurementWorkFlow));
sele.selectByIndex(index);
return this;
}
我不喜欢他们认为我正在扩展元素类