-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCFSelenium-1.5.cfm
More file actions
27 lines (26 loc) · 3.58 KB
/
CFSelenium-1.5.cfm
File metadata and controls
27 lines (26 loc) · 3.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
CFSelenium 1.5 - With Some Handy Helper Methods
A new version of <a href="http://github.com/bobsilverberg/CFSelenium" target="_blank">CFSelenium</a> was recently released which includes
a few helper methods that I've found useful. First off, I'd like to thank the fine folks on the <a href="http://quality.mozilla.org/teams/web-qa/" target="_blank">Mozilla Web QA</a> team,
from whom I borrowed the idea for these methods. I wrote a couple of tests for them in Python, and their Python base page object contains these methods.
While I agree that it makes sense to include these methods in a base page object, not everyone using CFSelenium is using the Page Object Model, and as I the creator and
co-maintainer of CFSelenium I figured I'd just make everyone's life simpler and include them directly in the client library.</p>
<p>The three methods, which are <em>waitForElementPresent</em>, <em>waitForElementVisible</em>, and <em>waitForElementNotVisible</em>, are helpful when testing applications that make use
of AJAX, or even just simple JavaScript. When you want to check that a page has responded to a user interaction, and the response is generated by JavaScript, you can often run
into timing issues in your Selenium tests. If you issue a <em>click</em> command and then immediately include an assert with a <em>getText</em> command in it, it may be that the
element that you are attempting to get hasn't been created by the browser yet. The same can be true when elements are shown or hidden. To address this issue the three methods mentioned
above can be used, each of which is described in greater detail below.</p>
<h3>Arguments</h3>
<p>Each of these methods accepts one required and one optional argument. The first argument, <em>locator</em>, is just that; the locator of the element that you want to wait for.
The second, optional, argument is <em>timeout</em>, which is a number, in milliseconds, that you want CFSelenium to wait for the element before it throws an exception.
The default value for <em>timeout</em> is 30000 (or 30 seconds), and this can be overridden in one of two ways. You can override the default for your entire test case by passing a value into
the <em>waitTimeout</em> argument of CFSelenium's <em>init</em> method.
You can also override the default on any call to any of these methods by passing a value into the second argument of the methods, which is <em>timeout</em>.</p>
<h3>waitFor Methods</h3>
<p>In case it isn't already completely obvious, here is what the waitFor methods do:<ul>
<li><em>waitForElementPresent</em> - Waits for the specified element to be added to the DOM. If the element is not present by the end of the timeout interval an exception is thrown.</li>
<li><em>waitForElementVisible</em> - Waits for the specified element to become visible. If the element is not present by the end of the timeout interval an exception is thrown.
Note that the element must be present in the DOM or the Selenium server will throw an exception immediately.</li>
<li><em>waitForElementNotVisible</em> - Waits for the specified element to become hidden. If the element is not present by the end of the timeout interval an exception is thrown.</li>
</ul></p>
<p>As always, the latest version is available via the <a href="http://cfselenium.riaforge.org/" target="_blank">CFSelenium RIAForge page</a> and via the <a href="http://github.com/bobsilverberg/CFSelenium" target="_blank">CFSelenium GitHub Project</a>.
The latter also includes a detailed <a href="https://github.com/bobsilverberg/CFSelenium/blob/master/readme.md" target="_blank">Readme file</a> which can help you get started using CFSelenium.</p>