Last active
March 19, 2016 09:54
-
-
Save hidepin/3aed92499e432e4e752b to your computer and use it in GitHub Desktop.
selenium remotewebdriver screenshot
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.openqa.selenium.TakesScreenshot; | |
import org.openqa.selenium.WebDriver; | |
import org.openqa.selenium.remote.Augmenter; | |
import org.openqa.selenium.remote.DesiredCapabilities; | |
import org.openqa.selenium.remote.RemoteWebDriver; | |
public class NavigateToAUrl { | |
public static void main(String[] args) { | |
DesiredCapabilities capabilities = DesiredCapabilities.firefox(); | |
RemoteWebDriver remoteWD = null; | |
try { | |
remoteWD = new RemoteWebDriver(new URL("http://192.168.137.225:4444/wd/hub"), capabilities); | |
remoteWD.get("file://C:/selenium/Chapter 2/HTML/Selectable.html"); | |
Thread.sleep(1000); | |
WebDriver augmentedDriver = new Augmenter().augment(remoteWD); | |
File screenshot = ((TakesScreenshot)augmentedDriver) | |
.getScreenshotAs(OutputType.FILE); | |
FileUtils.copyFile(screenshot, new File("C:/work/test.png")); | |
/* | |
File screenshot = (File) ((TakesScreenshot)remoteWD) | |
.getScreenshotAs(OutputType.FILE); | |
FileUtils.copyFile(screenshot, new File("C:/work/test.png")); | |
*/ | |
Thread.sleep(2000); | |
remoteWD.quit(); | |
} catch (InterruptedException | IOException e) { | |
e.printStackTrace(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment