Skip to content

Instantly share code, notes, and snippets.

@kimukou
Created March 29, 2011 05:45
Show Gist options
  • Save kimukou/891863 to your computer and use it in GitHub Desktop.
Save kimukou/891863 to your computer and use it in GitHub Desktop.
SeleniumScreenShotTest.groovy
C:\Documents and Settings\kimukou_26>netstat -an | grep 4444
TCP 0.0.0.0:4444 0.0.0.0:0 LISTENING
TCP 127.0.0.1:3593 127.0.0.1:4444 ESTABLISHED
TCP 127.0.0.1:4444 127.0.0.1:3593 ESTABLISHED
TCP [::]:4444 [::]:0 LISTENING 0
==setUp==
==setUp(SVI)==
==setUp(SVE)==
==setUp(CLI)==
==setUp(CLE)==
==testRun==
==tearDown==
JUnit 4 Runner, Tests: 1, Failures: 0, Time: 21547
Result: org.junit.runner.Result@6f29c8
//
// reference
// http://d.hatena.ne.jp/tan_go238/searchdiary?word=%2A%5Bgroovy%5D
// http://d.hatena.ne.jp/Yamashiro0217/20090309/1236602172
// http://www7b.biglobe.ne.jp/~archer/tryjunit4/tryjunit4.html
//
// using Groovy Console(alerdy embedded JUnit4)
//
@Grab(group='org.codehaus.mojo', module='selenium-maven-plugin', version='1.0')
@Grab(group='junit', module='junit', version='4.8.2')
//import junit.framework.TestCase
import org.junit.Test
import org.junit.BeforeClass
import org.junit.AfterClass
import org.openqa.selenium.server.SeleniumServer
import com.thoughtworks.selenium.DefaultSelenium
import com.thoughtworks.selenium.Selenium
public class SeleniumScreenShotTest {//extends TestCase {
private static SeleniumServer seleniumServer
protected static Selenium selenium
@BeforeClass
//protected
public static void setUp() throws Exception {
println "==setUp=="
seleniumServer = new SeleniumServer()
println "==setUp(SVI)=="
seleniumServer.start()
println "==setUp(SVE)=="
//selenium = new DefaultSelenium("localhost", 4444, "*firefox", "http://www.cloudtesting.com/")
//selenium = new DefaultSelenium("localhost", 4444, "*chrome", "http://www.cloudtesting.com/")
//selenium = new DefaultSelenium("localhost", 4444, "*iexplore", "http://www.cloudtesting.com/")
//[TODO] Windows need snapsIE(http://snapsie.sourceforge.net/ )
// untar and [ regsvr32 Snapsie.dll ]
// first testRun is AddOn OK ,next running is capture image
selenium = new DefaultSelenium("localhost", 4444, "*iexploreproxy", "http://www.cloudtesting.com/")
println "==setUp(CLI)=="
selenium.start()
println "==setUp(CLE)=="
}
@AfterClass
//protected
public static void tearDown() throws Exception {
println "==tearDown=="
selenium.stop()
seleniumServer.stop()
}
@Test
public void testRun() {
println "==testRun=="
selenium.open("http://www.cloudtesting.com/blog/2009/06/24/capturing-screen-shots-of-browsers-with-selenium-and-cloud-testing-part-1/")
selenium.captureEntirePageScreenshot("C://screenshot.png","")
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment