【发布时间】:2014-02-19 10:33:19
【问题描述】:
WebDriver driver = new FirefoxDriver();
driver.get("http://www.google.com/");
File scrFile = ((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE);
// Now you can do whatever you need to do with it, for example copy somewhere
FileUtils.copyFile(scrFile, new File("c:\\tmp\\screenshot.png"));
谁能告诉我
File scrFile = ((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE)
getScreenShotAs是TakesScreenshot接口中的方法......
(TakesScreenshot)driver,指的是什么???你能解释一下吗?
【问题讨论】:
-
(TakesScreenshot)驱动程序,在这里你定义了类,'TakesScreenshot'就像一个实现getScreenshotAs函数的对象。走遍全班观察概念
-
getScreenshotAs() 帮你截屏
标签: java selenium selenium-webdriver