Over a million developers have joined DZone.

Quick Tip: Controlling Execution Speed in CFSelenium

DZone 's Guide to

Quick Tip: Controlling Execution Speed in CFSelenium

· Mobile Zone ·
Free Resource

When you use Selenium IDE to play back the actions you've recorded on a web page (the clicks, the text input, etc.), you can control the waiting period between the execution of each command using the slider control on the left end of the tool bar:

Speed slider control

With CFSelenium, the way that you control the time period between executions is with the setSpeed(string milliseconds) function.  Once you set the execution speed with this function, the time period between executions will remain set at that length until you use setSpeed again.  So you could set the speed once within the setUp() function of your MXUnit test case...

public void function setUp() {
browserUrl = "http://local.test";
selenium = new CFSelenium.selenium(browserUrl, "localhost", 4444, "*firefox");

...or you could alter the speed within a test case function...

public void function testFormValidation() {
//Now Selenium will wait 3 seconds between each of the following command statements
selenium.type("firstName", "John");
selenium.type("lastName", "White");
//Setting the speed back down to 1 second

Knowing how to change the speed in CFSelenium is crucial if you're testing any sort of operation that might take a second or two to update the page, like an AJAX call that populates a drop-down box:  if the next command in your test requires that drop-down box to be populated, but CFSelenium tries to run that command before the AJAX call completes, either your test will fail or you'll get an error message from Selenium.  The setSpeed function lets you slow down the execution speed so your AJAX calls have time to do their work before the next step in the test.



Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}