有一些问题。我正在使用带有C#的webdriver。这是代码
ITakesScreenshot screenshotDriver = driver as ITakesScreenshot;
Screenshot screenshot = screenshotDriver.GetScreenshot();
screenshot.SaveAsFile("c:/Image_23.png", System.Drawing.Imaging.ImageFormat.Jpeg);
然后它会为该行抛出System.NullReferenceException:
Screenshot screenshot = screenshotDriver.GetScreenshot();
我错在哪里?
答案 0 :(得分:0)
当您将对象保留为null时,会发生System.NullReferenceException
。在您的代码中Screenshot = screenshot = screenshotDriver.GetScreenshot();
保留为null,请确保在尝试编译之前将值放入其中