Permalink
Browse files

Modified tag versions with new helper functions, created new tests.

  • Loading branch information...
1 parent 3b257d7 commit b6df1782f01ad8a6d09c4a2c16364dec521961e0 @bcswartz bcswartz committed Jun 22, 2011
@@ -13,6 +13,7 @@
<cffunction name="afterTests" output="false" access="public" returntype="any" hint="">
<!--- NOTE: this will only stop the Java if it was started by this test case --->
<cfset variables.selenium.stop() />
+ <!--- NOTE: this will only stop the Java server if it was started by this test case --->
<cfset variables.selenium.stopServer() />
</cffunction>
View
@@ -32,6 +32,7 @@
<cfargument required="false" type="string" name="seleniumJarPath" default="/cfselenium/Selenium-RC/selenium-server-standalone-2.0b2.jar" />
<cfargument required="false" type="boolean" name="verbose" default="false" />
<cfargument required="false" type="string" name="seleniumServerArguments" default="" />
+ <cfargument required="false" type="numeric" name="waitTimeout" default="30000" />
<cfset structAppend(variables,arguments,true) />
<cfset variables.sessionId= "" />
@@ -98,6 +99,51 @@
<cfthrow message="The Response of the Selenium RC is invalid: #response#" />
</cffunction>
+
+ <cffunction returntype="void" name="waitForElementPresent">
+ <cfargument required="true" type="string" name="locator" />
+ <cfargument required="false" type="numeric" name="timeout" default="#variables.waitTimeout#" />
+ <cfset var counter= 0>
+ <cfset var thread= "">
+ <cfloop condition="Not isElementPresent(arguments.locator)">
+ <cfset thread= CreateObject("java","java.lang.Thread") />
+ <cfset thread.sleep(100) />
+ <cfset counter= counter+100>
+ <cfif counter EQ arguments.timeout>
+ <cfthrow type="CFSelenium.elementNotFound" message="The element: #arguments.locator# was not found after #arguments.timeout/1000# seconds." / >
+ </cfif>
+ </cfloop>
+ </cffunction>
+
+ <cffunction returntype="void" name="waitForElementVisible">
+ <cfargument required="true" type="string" name="locator" />
+ <cfargument required="false" type="numeric" name="timeout" default="#variables.waitTimeout#" />
+ <cfset var counter= 0>
+ <cfset var thread= "">
+ <cfloop condition="Not isVisible(arguments.locator)">
+ <cfset thread= CreateObject("java","java.lang.Thread") />
+ <cfset thread.sleep(100) />
+ <cfset counter= counter+100>
+ <cfif counter EQ arguments.timeout>
+ <cfthrow type="CFSelenium.elementNotVisible" message="The element: #arguments.locator# was not visible after #arguments.timeout/1000# seconds." / >
+ </cfif>
+ </cfloop>
+ </cffunction>
+
+ <cffunction returntype="void" name="waitForElementNotVisible">
+ <cfargument required="true" type="string" name="locator" />
+ <cfargument required="false" type="numeric" name="timeout" default="#variables.waitTimeout#" />
+ <cfset var counter= 0>
+ <cfset var thread= "">
+ <cfloop condition="isVisible(arguments.locator)">
+ <cfset thread= CreateObject("java","java.lang.Thread") />
+ <cfset thread.sleep(100) />
+ <cfset counter= counter+100>
+ <cfif counter EQ arguments.timeout>
+ <cfthrow type="CFSelenium.elementStillVisible" message="The element: #arguments.locator# was still visible after #arguments.timeout/1000# seconds." / >
+ </cfif>
+ </cfloop>
+ </cffunction>
<cffunction returntype="string" name="getString">
<cfargument required="true" type="string" name="command" />
@@ -36,6 +36,9 @@
<cfset selenium.click("link=readme.md")>
<cfset selenium.waitForPageToLoad("30000")>
+ <cfset thread= CreateObject("java","java.lang.Thread") />
+ <cfset thread.sleep(1000) />
+
<cfset expected= "readme.md at master from bobsilverberg/CFSelenium - GitHub">
<cfset actual= selenium.getTitle()>
@@ -11,7 +11,7 @@
<cfset assertEquals("bobsilverberg/CFSelenium - GitHub", selenium.getTitle())>
<cfset variables.selenium.click("link=readme.md")>
<cfset variables.selenium.waitForPageToLoad("30000")>
- <cfset sleep(5000)>
+ <cfset sleep(1000)>
<cfset assertEquals("readme.md at master from bobsilverberg/cfselenium - github", variables.selenium.getTitle())>
<cfset variables.selenium.click("raw-url")>
<cfset variables.selenium.waitForPageToLoad("30000")>
@@ -45,47 +45,6 @@
</cfif>
</p>
- <p>Opening particular wiki page...</p>
- <cfflush />
-
- <cfset selenium.open("/pages/viewpage.action?pageId=786471")>
-
- <cfset linkArray= selenium.getAllLinks()>
- <p class="resultBlock">
- <span class="subhead">Hyperlinks on page (array)</span>
- <cfdump var="#linkArray#">
- <br />
- <cfif arrayLen(linkArray) GT 0>
- <span class="success">Passed</span>
- <cfelse>
- <span class="failure">Failed</span>
- </cfif>
- </p>
-
- <cfset locationString= selenium.getLocation()>
- <p class="resultBlock">
- <span class="subhead">Absolute URL (string)</span>
- <cfdump var="#locationString#">
- <br />
- <cfif Len(locationString) GT 0>
- <span class="success">Passed</span>
- <cfelse>
- <span class="failure">Failed</span>
- </cfif>
- </p>
-
- <cfset bodyText= selenium.getBodyText()>
- <p class="resultBlock">
- <span class="subhead">Body text of page (string)</span>
- <cfdump var="#bodyText#">
- <br />
- <cfif Len(bodyText) GT 0>
- <span class="success">Passed</span>
- <cfelse>
- <span class="failure">Failed</span>
- </cfif>
- </p>
-
<p>Testing parsing of comma-separated values...</p>
<cfflush />
@@ -34,15 +34,6 @@
<cfset debug(selenium.getBodyText())>
</cffunction>
-
- <!---<cffunction name="testOpen">
-
- <cfset selenium.open("/pages/viewpage.action?pageId=786471")>
- <cfset debug(selenium.getAllLinks())>
- <cfset debug(selenium.getLocation())>
- <cfset debug(selenium.getBodyText())>
-
- </cffunction>--->
</cfcomponent>

0 comments on commit b6df178

Please sign in to comment.