Skip to content

Commit

Permalink
Merge pull request teamcfadvance#22 from adrianblynch/dynamicHostTests
Browse files Browse the repository at this point in the history
Dynamic host tests
  • Loading branch information
DannyCork committed Jun 22, 2014
2 parents 40425ac + 9a5a28b commit 24ece92
Show file tree
Hide file tree
Showing 4 changed files with 86 additions and 81 deletions.
5 changes: 4 additions & 1 deletion server.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -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()">
Expand Down
96 changes: 48 additions & 48 deletions test/cf7_cf8/waitForTest_cf7.cfm
Original file line number Diff line number Diff line change
Expand Up @@ -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 />
Expand All @@ -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>
Expand All @@ -46,7 +46,7 @@
<cfset actual= cfcatch.type />
</cfcatch>
</cftry>

<p class="resultBlock">
Expected Selenium error type: #expected# <br />
Actual Selenium type #actual#<br />
Expand All @@ -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 />
Expand All @@ -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 />
Expand All @@ -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 />
Expand All @@ -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>
Expand All @@ -118,7 +118,7 @@
<cfset actual= cfcatch.type />
</cfcatch>
</cftry>

<p class="resultBlock">
Expected Selenium error type: #expected# <br />
Actual Selenium type #actual#<br />
Expand All @@ -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 />
Expand All @@ -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 />
Expand All @@ -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 />
Expand All @@ -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>
Expand All @@ -192,7 +192,7 @@
<cfset actual= cfcatch.type />
</cfcatch>
</cftry>

<p class="resultBlock">
Expected Selenium error type: #expected# <br />
Actual Selenium type #actual#<br />
Expand All @@ -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 />
Expand All @@ -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 />
Expand All @@ -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 />
Expand All @@ -250,9 +250,9 @@
<span class="failure">Failed</span>
</cfif>
</p>

<cfset selenium.stopServer()>

<p>DONE</p>

</cfoutput>
25 changes: 13 additions & 12 deletions test/cf7_cf8/waitForTest_cf8.cfc
Original file line number Diff line number Diff line change
@@ -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>

Loading

0 comments on commit 24ece92

Please sign in to comment.