我有 PageObject ,其中包含50个元素,用于描述页面上的所有元素。有30多个测试使用此元素。但是,我该如何仅使用测试所需的那些元素,而不将其全部初始化。
public class DetailReportingPage extends BasePage {
public static final String PAGE_URL = ReportingPage.PAGE_URL + ":ReportingDetailTab";
public Button detailSubTabBtn = new Button(By.id("DetailSubTab"));
public TextField reportNameSelect = new TextField(By.id("IR.IrReportingDetailSubTab.ComboBox.ReportName-input"));
public DropDown reportNameDropDown = new DropDown(By.id("IR.IrReportingDetailSubTab.ComboBox.ReportName-trigger"));
public TextField reportNameInput = new TextField(By.id("IR.IrReportingDetailSubTab.TextField.ReportName-input"));
public TextField fileTypeHistory = new TextField(By.id("IR.IrReportingDetailSubTab.ComboBox.FileType-input"));
public TextField fileTypeSummary = new TextField(By.id("IR.IrReportingDetailSubTab.ComboBox.FileType2-input"));
public TextField valueDate = new TextField(By.id("IR.IrReportingDetailSubTab.DateField.Element22-input"));
public TextField curveDate = new TextField(By.id("IR.IrReportingDetailSubTab.DateField.Element23-input"));
public CheckBox includeAll = new CheckBox(By.id("IR.IrReportingDetailSubTab.IdAwareCheckBox.Element27"));
public Button editBtn = new Button(By.xpath("//div[contains(@__gwtcellbasedwidgetimpldispatchingfocus,'true')][.//table[contains(@class,'mainTable')]][.//div[text()='Edit']]"));
public Button deleteBtn = new Button(By.xpath("//div[contains(@__gwtcellbasedwidgetimpldispatchingfocus,'true')][.//table[contains(@class,'mainTable')]][.//div[text()='Delete']]"));
public Button runReportBtn = new Button(By.xpath("//div[contains(@__gwtcellbasedwidgetimpldispatchingfocus,'true')][.//table[contains(@class,'mainTable')]][.//div[text()='Run Report']]"));
public Button mtmHistoryRbtn = new Button(By.xpath("//label[text()='MTM History']/preceding-sibling::input"));
public Button meSummaryRbtn = new Button(By.xpath("//label[text()='ME Summary']/preceding-sibling::input"));
public Button mtmDetailRbtn = new Button(By.xpath("//label[text()='MTM Detail']/preceding-sibling::input"));
//region for MTM History Type
public CheckBox cleanMarketValueChbx = new CheckBox(By.xpath("//label[text()='Clean Market Value']/preceding-sibling::input"));
public CheckBox dirtyMarketValueChbx = new CheckBox(By.xpath("//label[text()='(Dirty) Market Value']/preceding-sibling::input"));
public CheckBox cvaChbx = new CheckBox(By.xpath("//table[contains(@class, 'ReportMTMHistory')]//label[text()='CVA']/preceding-sibling::input"));
public Button curveDateRbtn = new Button(By.xpath("//label[text()='Curve Date']/preceding-sibling::input"));
public Button staticDateRbtn = new Button(By.xpath("//label[text()='Static Date']/preceding-sibling::input"));
public TextField date = new TextField(By.id("IR.IrReportingDetailSubTab.DateField.Element17-input"));
public TextField startDate = new TextField(By.id("IR.IrReportingDetailSubTab.DateField.StartDate-input"));
public CheckBox scheduleChbx = new CheckBox(By.xpath("//label[text()='Schedule']/preceding-sibling::input"));
public CheckBox manualInputChbx = new CheckBox(By.xpath("//label[text()='Manual Input']/preceding-sibling::input"));
public CheckBox summaryColumnChbx = new CheckBox(By.xpath("//table[contains(@class, 'ReportMTMHistory')]//label[text()='Summary Column']/preceding-sibling::input"));
public CheckBox individualTradeChbx = new CheckBox(By.xpath("//table[contains(@class, 'ReportMTMHistory')]//label[text()='Individual Trade']/preceding-sibling::input"));
public TextField numOfDates = new TextField(By.id("IR.IrReportingDetailSubTab.NumberField.#ofDates-input"));
public TextField frequency = new TextField(By.id("IR.IrReportingDetailSubTab.ComboBox.Frequency-input"));
public TextField firstMonth = new TextField(By.id("IR.IrReportingDetailSubTab.ComboBox.FirstMonth-input"));
public Table scheduleDates = new Table(By.xpath("(//div[contains(@class, 'scroller')]//table/tbody)[4]"));
public TextField dateField = new TextField(By.id("IR.IrReportingDetailSubTab.ComboBox.Date-input"));
}