我正在尝试使用LeanFT中的getOpenURL()
获取打开的浏览器的URL。
我的代码如下:
String url = BrowserFactory.attach(new BrowserDescription.Builder().build()).getOpenURL();
System.out.println("Opened Browser URL is:" +url);
它执行时出现以下错误:
Exception in thread "main" com.hp.lft.sdk.ReplayObjectNotFoundException: attachApplication
at com.hp.lft.sdk.internal.ReplayExceptionFactory$1.create(ReplayExceptionFactory.java:34)
at com.hp.lft.sdk.internal.ReplayExceptionFactory.createOrDefault(ReplayExceptionFactory.java:197)
at com.hp.lft.sdk.internal.ReplayExceptionFactory.createOrDefault(ReplayExceptionFactory.java:21)
at com.hp.lft.sdk.internal.web.BrowserErrorHandler.onError(BrowserErrorHandler.java:38)
at com.hp.lft.sdk.internal.CommunicationClientImpl.handleError(CommunicationClientImpl.java:221)
at com.hp.lft.sdk.internal.CommunicationClientImpl.send(CommunicationClientImpl.java:96)
at com.hp.lft.sdk.web.BrowserFactory$BrowserFactoryInstance$3.invoke(BrowserFactory.java:142)
at com.hp.lft.sdk.web.BrowserFactory$BrowserFactoryInstance$3.invoke(BrowserFactory.java:131)
at com.hp.lft.sdk.internal.TestObjectOperationWrapper.executeWithEvents(TestObjectOperationWrapper.java:120)
at com.hp.lft.sdk.internal.TestObjectOperationWrapper.executeWithEvents(TestObjectOperationWrapper.java:97)
at com.hp.lft.sdk.web.BrowserFactory$BrowserFactoryInstance.attach(BrowserFactory.java:150)
at com.hp.lft.sdk.web.BrowserFactory.attach(BrowserFactory.java:61)
at com.optum.comet.utilities.TestWebHierarchy.main(TestWebHierarchy.java:88)
我做错了什么,请您指教吗?
答案 0 :(得分:0)
ReplayObjectNotFoundException
说找不到您尝试使用的对象。基本上,浏览器描述为空(new BrowserDescription.Builder()
)
打开哪种类型的浏览器? Firefox,Chrome?
如果您对打开的浏览器一无所知,则可以使用BrowserFactory.GetAllOpenBrowsers
,循环浏览所有浏览器并获取每个浏览器的网址