I am trying to get the URL of a Opened Browser using getOpenURL() in LeanFT.
My code is below:
String url = BrowserFactory.attach(new BrowserDescription.Builder().build()).getOpenURL();
System.out.println("Opened Browser URL is:" +url);
It executes with the following error:
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)
What am I doing wrong, could you please advise?
ReplayObjectNotFoundExceptionsays that the object you tried to use is not found. Basically, the browser description is empty (new BrowserDescription.Builder())What type of browser is opened? Firefox, Chrome?
If you don't know anything about the opened browsers, you could use
BrowserFactory.GetAllOpenBrowsers, loop over all the browsers and get the url for each one of them