selenium2-visualdiff icon indicating copy to clipboard operation
selenium2-visualdiff copied to clipboard

NullPointerException

Open Mihalavr opened this issue 9 years ago • 1 comments

Hello Conny, I'm trying to run your code and getting NPE. I think some major initiation step is missing in your readme file. You are creating a new TakeScreenshotRule object: @Rule public TakesScreenshotRule screenshot = new TakesScreenshotRule(); ...and then call it's takeScreenshot(driver) method which in turn calls: public ScreenshotMeta takeScreenshot(String id, WebDriver driver) throws IOException { return this.screenshotManager.takeScreenshot(driver, id); }

BUT screenshotManager is not initialized at this point and that is why I get NPE (screenshotManager = NULL). screenshotManager is initialized in: public Statement apply(Statement base, FrameworkMethod method, Object target) { this.screenshotManager = new ScreenshotManager(target.getClass(), method.getName()); return base; } ....but this method is not called from anywhere.

Could you please provide a bit more details on how to make this code work?

Thank you in advance, Michael

Mihalavr avatar Jan 19 '16 18:01 Mihalavr

Sorry for the late reply.

Do you run your test with a junit 4 runner? @Rule is a junit 4 annotation!

kreyssel avatar Aug 10 '16 12:08 kreyssel