的方法,我有以下代码:截断在Java
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();
请粘贴到你的回应全班?
重复:http://stackoverflow.com/questions/5835943/truncate-the-reference-to-class – mellamokb 2011-04-29 19:26:29