Thursday, August 8, 2013

Running Selenium with Groovy on PhantomJS

There is script that runs and takes snapshot of PhantomJS with Selenium:


@Grab("com.github.detro.ghostdriver:phantomjsdriver:1.0.1")

import org.openqa.selenium.*
import org.openqa.selenium.phantomjs.PhantomJSDriver
import org.openqa.selenium.remote.DesiredCapabilities

new PhantomJSDriver(new DesiredCapabilities()).with {
    manage().window().setSize(new Dimension(1028, 768))
 get("http://www.google.com")
 getScreenshotAs(OutputType.FILE).renameTo("screenshot.png")
 quit()
}



No comments:

Post a Comment