我有以下代码:
public class Search {
private Desktop desktop = new Desktop();
@Before
public void baseState() {
BrowserBaseState baseState = new BrowserBaseState("silk4j.settings");
baseState.execute(desktop);
}
@Test
public void searchNames() {
desktop.<BrowserApplication>find("//BrowserApplication").<BrowserWindow>find("//BrowserWindow").<DomButton>find("//INPUT[@id='edit-submit']").select();
}
}
我能够将测试方法截断为:
public class Search {
private Desktop desktop = new Desktop();
BrowserApplication app;
@Before
public void baseState() {
BrowserBaseState baseState = new BrowserBaseState("silk4j.settings");
app = baseState.execute(desktop);
}
@Test
public void searchNames() {
app.<BrowserWindow>find("//BrowserWindow").<DomButton>find("//INPUT[@id='edit-submit']").select();
}
如何进一步截断该方法?我希望能够使用这样的东西:
win.<DomButton>find("//INPUT[@id='edit-submit']").select();
而不是这个笨重的长:
desktop.<BrowserApplication>find("//BrowserApplication").<BrowserWindow>find("//BrowserWindow").<DomButton>find("//INPUT[@id='edit-submit']").select();
请在您的回复中粘贴整个班级?