WebElement#getScreenShotAs(OutputType.File) not working

前端 未结 4 586
时光取名叫无心
时光取名叫无心 2021-01-21 05:08

I am trying to use WebElement#getScreenShotAs(OutputType.FILE) feature added in selenium webdriver 2.47.0 version on Firefox Browser Code

public         


        
4条回答
  •  感动是毒
    2021-01-21 05:32

    It should be something like this.

    File screenS = ((TakesScreenshot)(driver)).getScreenshotAs(OutputType.FILE);
    FileUtils.copyFile(screenS, new File("C:\\akshay\\del\\screenshots\\1.jpg"));
    

    replace the above code with

    element.getScreenshotAs(OutputType.FILE);
            File destination=new File("Image.png");
            FileUtils.copyFile(null, destination);
    

提交回复
热议问题