0

I try to take screenshot from current page under test with LeanFT to attach to report file.

RenderedImage img = browser.getPage().getSnapshot();
Reporter.reportEvent("Login","Login successful", Status.Passed, img);

I get error message:

com.hp.lft.sdk.GeneralLeanFtException: ERROR at com.hp.lft.sdk.internal.ReplayExceptionFactory.createDefault(ReplayExceptionFactory.java:202) at com.hp.lft.sdk.internal.ReplayExceptionFactory.createOrDefault(ReplayExceptionFactory.java:194) at com.hp.lft.sdk.internal.ReplayExceptionFactory.createOrDefault(ReplayExceptionFactory.java:21) at com.hp.lft.sdk.internal.TestObjectExecuterBehaviorBase$ReplayErrorHandler.onError(TestObjectExecuterBehaviorBase.java:65) 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.internal.TestObjectExecuterBehavior.executeMethod(TestObjectExecuter.java:44) at com.hp.lft.sdk.internal.TestObjectBase.executeMethod(TestObjectBase.java:123) at com.hp.lft.sdk.internal.TestObjectBase.getSnapshot(TestObjectBase.java:197)

Method in reference(https://admhelp.microfocus.com/leanft/en/14.03/JavaSDKReference/com/hp/lft/report/Reporter.html):

reportEvent(java.lang.String stepName, java.lang.String description, Status status, java.lang.Exception ex, java.awt.image.RenderedImage image) Adds a custom step to the LeanFT including the provided exception and image object.

plaidshirt
  • 5,189
  • 19
  • 91
  • 181
  • 1
    The Exception is raised in getSnapshot() according to the stackTrace - does not even reaches the Report. Possible causes - mostly the Object does not exist or is not fully loaded. An exotic cause might be that LeanFT cannot use the Image Capture Driver. – Bela Tamas Jozsa Jul 05 '18 at 18:02
  • I imported all the necessary classes. How could I continue debugging? – plaidshirt Jul 05 '18 at 20:53
  • My comment was not related to imports but to the browser Object. Is it visible on the screen, does the exist() method returns true? what about the object returned by getPage() afterwards. Only if the UI Obejcts represented by these 2 methods are visible the screenshot will be taken – Bela Tamas Jozsa Jul 05 '18 at 22:02
  • I get NullPointerexception for browser.exists() , but I use browser on the same class. – plaidshirt Jul 06 '18 at 09:49
  • 1
    then something is not okay with your browser variable. Is not initalized. Can you share the full code? – Bela Tamas Jozsa Jul 06 '18 at 15:08
  • @BelaTamasJozsa : I use this code: `Browser browser = BrowserFactory.launch(BrowserType.CHROME); browser.navigate(env.LOGIN);` – plaidshirt Jul 08 '18 at 20:04
  • also, no need to get the snapshot of the page, do it directly on the `browser`: `browser.getSnapshot()` – Adelin Jul 10 '18 at 12:06
  • @Adelin : I already tried that too. – plaidshirt Jul 10 '18 at 14:37
  • It occurs with Firefox as well? Or Phantom JS? What OS is this? Try updating chrome and LeanFT – Adelin Jul 13 '18 at 14:05
  • @Adelin : It happens with Chrome and it is already the newest one. – plaidshirt Jul 17 '18 at 05:29
  • What LeanFT version are you using? What is the browser agent version? – Adelin Jul 17 '18 at 05:32
  • @Adelin : I use LeanFT 14.02 and plugin version 14.3.3652.1. – plaidshirt Jul 17 '18 at 05:35
  • 1
    That could be the problem. The plugin version is ahead. You should try to downgrade to 14.2 (or update leanft) – Adelin Jul 17 '18 at 05:36

0 Answers0