From 06f795eaada5c1216b4b9a681b3d1d95ea54ec91 Mon Sep 17 00:00:00 2001 From: julianofernandes Date: Wed, 27 Mar 2013 12:33:31 -0300 Subject: [PATCH] Creating a way to use an already up instance of SeleniumServer --- SeleniumRcGrailsPlugin.groovy | 2 +- scripts/_Selenium.groovy | 9 +++++++-- scripts/_SeleniumConfig.groovy | 2 ++ src/templates/conf/SeleniumConfigTemplate.groovy | 6 ++++++ 4 files changed, 16 insertions(+), 3 deletions(-) diff --git a/SeleniumRcGrailsPlugin.groovy b/SeleniumRcGrailsPlugin.groovy index dca23c3..b6a8f74 100644 --- a/SeleniumRcGrailsPlugin.groovy +++ b/SeleniumRcGrailsPlugin.groovy @@ -16,7 +16,7 @@ class SeleniumRcGrailsPlugin { - def version = "1.0.2" + def version = "1.0.2.StartSelenium-Fix" def grailsVersion = "1.2.0 > *" def dependsOn = [:] def pluginExcludes = [ diff --git a/scripts/_Selenium.groovy b/scripts/_Selenium.groovy index 37ce2a7..a2edc2e 100644 --- a/scripts/_Selenium.groovy +++ b/scripts/_Selenium.groovy @@ -40,7 +40,9 @@ target(registerSeleniumTestType: "Registers the selenium test type with the appr } target(startSelenium: "Starts Selenium and launches a browser") { - startSeleniumServer() + if( seleniumConfig.selenium.server.start ) { + startSeleniumServer() + } // this isn't done in initial config construction as it requires app config to be loaded and use of -clean can cause problems depends(determineSeleniumUrl) @@ -54,7 +56,10 @@ target(stopSelenium: "Stops Selenium") { event "StatusUpdate", ["Stopping Selenium session"] seleniumRunner.stopSelenium() selenium = null - stopSeleniumServer() + + if( seleniumConfig.selenium.server.start ) { + stopSeleniumServer() + } } target(registerSeleniumTestListeners: "Registers listeners for the Selenium test lifecycle") { diff --git a/scripts/_SeleniumConfig.groovy b/scripts/_SeleniumConfig.groovy index 2986004..062f3da 100644 --- a/scripts/_SeleniumConfig.groovy +++ b/scripts/_SeleniumConfig.groovy @@ -19,6 +19,7 @@ import grails.util.GrailsUtil seleniumUrl = null seleniumConfig = null + target(loadSeleniumConfig: "Loads Selenium config into seleniumConfig variable") { event "StatusUpdate", ["loading selenium config"] depends(loadDefaultConfig, mergeApplicationConfig, mergeSystemProperties) @@ -36,6 +37,7 @@ selenium { slow = false singleWindow = true windowMaximize = false + startSeleniumServer = true screenshot { dir = "${testReportsDir.path.replace(File.separator, '/')}/screenshots" onFail = false diff --git a/src/templates/conf/SeleniumConfigTemplate.groovy b/src/templates/conf/SeleniumConfigTemplate.groovy index d6a6703..bc3ac1c 100644 --- a/src/templates/conf/SeleniumConfigTemplate.groovy +++ b/src/templates/conf/SeleniumConfigTemplate.groovy @@ -1,4 +1,5 @@ selenium { + /* slow = false // true to run tests in slow resources mode singleWindow = true // true for single window mode, false for multi-window mode @@ -6,14 +7,19 @@ selenium { url = null // the base URL for tests, defaults to Grails server url defaultTimeout = 60000 // the timeout after which selenium commands will fail windowMaximize = false // true to maximize browser on startup + screenshot { dir = "./target/test-reports/screenshots" // directory where screenshots are placed relative to project root onFail = false // true to capture screenshots on test failures } + server { host = "localhost" // the host the selenium server will run on port = 4444 // the port the selenium server will run on + start = true // false to use another instance (already up) of selenium server with same config above } + userExtensions = "" // path to user extensions javascript file */ + } \ No newline at end of file