截断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();
请将整个课程粘贴到您的回复中?
I have the following code:
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();
}
}
I was able to truncate the Test method to this:
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();
}
How do I truncate the method even further? I would like to be able to use something like this:
win.<DomButton>find("//INPUT[@id='edit-submit']").select();
instead of this chunky long:
desktop.<BrowserApplication>find("//BrowserApplication").<BrowserWindow>find("//BrowserWindow").<DomButton>find("//INPUT[@id='edit-submit']").select();
Please paste the whole class in your response?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)