Permalink
Browse files

Merge pull request #22 from adrianblynch/dynamicHostTests

Dynamic host tests
  • Loading branch information...
2 parents 40425ac + 9a5a28b commit 24ece92a9ea488c1475d1e86f82b83c25449cbea @DannyCork DannyCork committed Jun 22, 2014
Showing with 86 additions and 81 deletions.
  1. +4 −1 server.cfc
  2. +48 −48 test/cf7_cf8/waitForTest_cf7.cfm
  3. +13 −12 test/cf7_cf8/waitForTest_cf8.cfc
  4. +21 −20 test/cf9/waitForTest.cfc
View
@@ -20,10 +20,13 @@
<cfset var loopStart = getTickCount()>
<cfif not serverIsRunning()>
<cfset jarPath= "#expandPath(variables.seleniumJarPath)#">
+ <cfif not fileExists(jarPath)>
+ <cfthrow message="Could not find #jarPath#">
+ </cfif>
<cfset isRunning = false>
<cfset args = "-jar ""#jarPath#"" #variables.seleniumServerArguments#">
<cfset logStatus( text="!!!! STARTING Selenium RC with jar path: #jarPath#! args were: #args#." )>
- <cfexecute name="java" arguments="#args#">
+ <cfexecute name="java" arguments="#args#" />
<!--- we need to give the server time to fully start --->
<cfloop condition="NOT serverIsRunning()">
@@ -8,24 +8,24 @@
<h2>waitForTest for CFSelenium on ColdFusion 7</h2>
<cfoutput>
-
+
<p>Instantiating selenium...</p>
-
- <cfset browserUrl = "http://localhost/CFSelenium/test/fixture/">
+
+ <cfset browserUrl = mid(cgi.request_url, 1, findNoCase("/CFSelenium/test/", cgi.request_url)) & "CFSelenium/test/fixture/">
<cfset browserCommand= "*firefox">
- <cfset selenium= createObject("component","cfselenium.selenium_tags").init(waitTimeout=5000)>
+ <cfset selenium= createObject("component","cfselenium.selenium_tags").init(waitTimeout=1500)>
<cfset selenium.start(browserUrl,browserCommand)>
<cfset selenium.setTimeout(30000)>
- <cfset selenium.open("http://localhost/cfselenium/test/fixture/waitForFixture.htm") />
-
+ <cfset selenium.open(browserUrl & "waitForFixture.htm") />
+
<p>Checking if "alwaysPresentAndVisible" exists on the page (should find it)...</p>
<cfflush />
-
+
<cfset selenium.waitForElementPresent("alwaysPresentAndVisible") />
-
+
<cfset expected= "alwaysPresentAndVisible">
<cfset actual= selenium.getText("alwaysPresentAndVisible")>
-
+
<p class="resultBlock">
Expected Selenium result: #expected# <br />
Actual Selenium result: #actual#<br />
@@ -35,9 +35,9 @@
<span class="failure">Failed</span>
</cfif>
</p>
-
+
<p>Will look for "neverPresent" on the page (should NOT find it and throw an error after 5 seconds)...</p>
-
+
<cfflush />
<cfset expected="CFSelenium.elementNotFound">
<cftry>
@@ -46,7 +46,7 @@
<cfset actual= cfcatch.type />
</cfcatch>
</cftry>
-
+
<p class="resultBlock">
Expected Selenium error type: #expected# <br />
Actual Selenium type #actual#<br />
@@ -56,12 +56,12 @@
<span class="failure">Failed</span>
</cfif>
</p>
-
+
<p>Will look for "presentAfterAPause", which at first will not be found...</p>
<cfflush />
<cfset expected= false>
<cfset actual= selenium.isElementPresent("presentAfterAPause")>
-
+
<p class="resultBlock">
Expected Selenium result: #expected# <br />
Actual Selenium result: #actual#<br />
@@ -71,14 +71,14 @@
<span class="failure">Failed</span>
</cfif>
</p>
-
+
<p>Will now create "presentAfterAPause" via Javascript and check again...</p>
<cfflush />
<cfset selenium.click("createElement") />
<cfset selenium.waitForElementPresent("presentAfterAPause") />
<cfset expected="presentAfterAPause" />
<cfset actual= selenium.getText("presentAfterAPause") />
-
+
<p class="resultBlock">
Expected Selenium result: #expected# <br />
Actual Selenium result: #actual#<br />
@@ -88,16 +88,16 @@
<span class="failure">Failed</span>
</cfif>
</p>
-
-
+
+
<p>Checking if "alwaysPresentAndVisible" is visible on the page (should find it)...</p>
<cfflush />
-
+
<cfset selenium.waitForElementVisible("alwaysPresentAndVisible") />
-
+
<cfset expected= "alwaysPresentAndVisible">
<cfset actual= selenium.getText("alwaysPresentAndVisible")>
-
+
<p class="resultBlock">
Expected Selenium result: #expected# <br />
Actual Selenium result: #actual#<br />
@@ -107,9 +107,9 @@
<span class="failure">Failed</span>
</cfif>
</p>
-
+
<p>Will look for "neverVisible" on the page (should NOT see it and throw an error after 5 seconds)...</p>
-
+
<cfflush />
<cfset expected="CFSelenium.elementNotVisible">
<cftry>
@@ -118,7 +118,7 @@
<cfset actual= cfcatch.type />
</cfcatch>
</cftry>
-
+
<p class="resultBlock">
Expected Selenium error type: #expected# <br />
Actual Selenium type #actual#<br />
@@ -128,12 +128,12 @@
<span class="failure">Failed</span>
</cfif>
</p>
-
+
<p>Will look for "becomesVisible", which at first will not be found...</p>
<cfflush />
<cfset expected= false>
<cfset actual= selenium.isVisible("becomesVisible")>
-
+
<p class="resultBlock">
Expected Selenium result: #expected# <br />
Actual Selenium result: #actual#<br />
@@ -143,14 +143,14 @@
<span class="failure">Failed</span>
</cfif>
</p>
-
+
<p>Will now make "becomesVisible" visible via Javascript and check again...</p>
<cfflush />
<cfset selenium.click("showElement") />
<cfset selenium.waitForElementVisible("becomesVisible") />
<cfset expected="becomesVisible" />
<cfset actual= selenium.getText("becomesVisible") />
-
+
<p class="resultBlock">
Expected Selenium result: #expected# <br />
Actual Selenium result: #actual#<br />
@@ -160,16 +160,16 @@
<span class="failure">Failed</span>
</cfif>
</p>
-
-
+
+
<p>Testing that "neverVisible" is not visible on the page...</p>
<cfflush />
-
+
<cfset selenium.waitForElementNotVisible("neverVisible") />
-
+
<cfset expected= "">
<cfset actual= selenium.getText("neverVisible")>
-
+
<p class="resultBlock">
Expected Selenium result: #expected# <br />
Actual Selenium result: #actual#<br />
@@ -179,11 +179,11 @@
<span class="failure">Failed</span>
</cfif>
</p>
-
-
-
+
+
+
<p>Will test that "alwaysPresentAndVisible" is NOT visible (which is not true and will throw an error after 5 seconds)...</p>
-
+
<cfflush />
<cfset expected="CFSelenium.elementStillVisible">
<cftry>
@@ -192,7 +192,7 @@
<cfset actual= cfcatch.type />
</cfcatch>
</cftry>
-
+
<p class="resultBlock">
Expected Selenium error type: #expected# <br />
Actual Selenium type #actual#<br />
@@ -202,12 +202,12 @@
<span class="failure">Failed</span>
</cfif>
</p>
-
+
<p>Will look for "becomesInvisible", which at first will be visible...</p>
<cfflush />
<cfset expected= true>
<cfset actual= selenium.isVisible("becomesInvisible")>
-
+
<p class="resultBlock">
Expected Selenium result: #expected# <br />
Actual Selenium result: #actual#<br />
@@ -217,14 +217,14 @@
<span class="failure">Failed</span>
</cfif>
</p>
-
+
<p>Will now make "becomesInvisible" invisible via Javascript and check again...</p>
<cfflush />
<cfset selenium.click("hideElement") />
<cfset selenium.waitForElementNotVisible("becomesInvisible") />
<cfset expected="" />
<cfset actual= selenium.getText("becomesInvisible") />
-
+
<p class="resultBlock">
Expected Selenium result: #expected# <br />
Actual Selenium result: #actual#<br />
@@ -234,13 +234,13 @@
<span class="failure">Failed</span>
</cfif>
</p>
-
+
<p>Stopping selenium...</p>
<cfset selenium.stop()>
-
+
<cfset expected= 0>
<cfset actual= Len(selenium.getSessionId())>
-
+
<p class="resultBlock">
Expected Selenium sessionId length: #expected# <br />
Actual Selenium sessionId length: #actual#<br />
@@ -250,9 +250,9 @@
<span class="failure">Failed</span>
</cfif>
</p>
-
+
<cfset selenium.stopServer()>
-
+
<p>DONE</p>
-
+
</cfoutput>
@@ -1,64 +1,65 @@
-<cfcomponent extends="cfselenium.CFSeleniumTestCase_Tags" >
+<cfcomponent extends="cfselenium.CFSeleniumTestCase_Tags">
<cffunction name="beforeTests">
- <cfset browserUrl = "http://localhost/CFSelenium/test/fixture/">
+ <cfset variables.baseTestURL = mid(cgi.request_url, 1, findNoCase("/CFSelenium/test/", cgi.request_url)) & "CFSelenium/test/">
+ <cfset browserUrl = variables.baseTestURL & "fixture/">
<cfset browserCommand= "*firefox">
<cfset selenium= createObject("component","cfselenium.selenium_tags").init(waitTimeout=5000)>
<cfset selenium.start(browserUrl,browserCommand)>
<cfset selenium.setTimeout(30000)>
</cffunction>
<cffunction name="setup">
- <cfset selenium.open("http://localhost/cfselenium/test/fixture/waitForFixture.htm") />
+ <cfset selenium.open(variables.baseTestURL & "fixture/waitForFixture.htm") />
</cffunction>
<cffunction name="waitForElementPresentShouldFindElementThatIsAlreadyThere">
<cfset selenium.waitForElementPresent("alwaysPresentAndVisible") />
<cfset assertEquals("alwaysPresentAndVisible",selenium.getText("alwaysPresentAndVisible")) />
</cffunction>
-
+
<cffunction name="waitForElementPresentShouldThrowIfElementIsNeverThere" mxunit:expectedException="CFSelenium.elementNotFound">
<cfset selenium.waitForElementPresent("neverPresent") />
</cffunction>
-
+
<cffunction name="waitForElementPresentShouldFindElementThatAppears">
<cfset assertEquals(false,selenium.isElementPresent("presentAfterAPause")) />
<cfset selenium.click("createElement") />
<cfset selenium.waitForElementPresent("presentAfterAPause") />
<cfset assertEquals("presentAfterAPause",selenium.getText("presentAfterAPause")) />
</cffunction>
-
+
<cffunction name="waitForElementVisibleShouldFindElementThatIsAlreadyThere">
<cfset selenium.waitForElementVisible("alwaysPresentAndVisible") />
<cfset assertEquals("alwaysPresentAndVisible",selenium.getText("alwaysPresentAndVisible")) />
</cffunction>
-
+
<cffunction name="waitForElementVisibleShouldThrowIfElementIsNeverVisible" mxunit:expectedException="CFSelenium.elementNotVisible">
<cfset selenium.waitForElementVisible("neverVisible") />
</cffunction>
-
+
<cffunction name="waitForElementVisibleShouldFindElementThatAppears">
<cfset assertEquals(false,selenium.isVisible("becomesVisible")) />
<cfset selenium.click("showElement") />
<cfset selenium.waitForElementVisible("becomesVisible") />
<cfset assertEquals("becomesVisible",selenium.getText("becomesVisible")) />
</cffunction>
-
+
<cffunction name="waitForElementNotVisibleShouldSucceedIfElementIsAlreadyInvisible">
<cfset selenium.waitForElementNotVisible("neverVisible") />
<cfset assertEquals("",selenium.getText("neverVisible")) />
</cffunction>
-
+
<cffunction name="waitForElementNotVisibleShouldThrowIfElementIsAlwaysVisible" mxunit:expectedException="CFSelenium.elementStillVisible">
<cfset selenium.waitForElementNotVisible("alwaysPresentAndVisible") />
</cffunction>
-
+
<cffunction name="waitForElementNotVisibleShouldSucceedIfElementDisappears">
<cfset assertEquals(true,selenium.isVisible("becomesInvisible")) />
<cfset selenium.click("hideElement") />
<cfset selenium.waitForElementNotVisible("becomesInvisible") />
<cfset assertEquals("",selenium.getText("becomesInvisible")) />
</cffunction>
-
+
</cfcomponent>
Oops, something went wrong.

0 comments on commit 24ece92

Please sign in to comment.