Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Quick Tip: Controlling Execution Speed in CFSelenium

DZone's Guide to

Quick Tip: Controlling Execution Speed in CFSelenium

· Mobile Zone
Free Resource

Download this comprehensive Mobile Testing Reference Guide to help prioritize which mobile devices and OSs to test against, brought to you in partnership with Sauce Labs.

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");
selenium.start();
selenium.setTimeout(30000);
selenium.setSpeed("1000");
}

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

public void function testFormValidation() {
selenium.open("blah/index.cfm?event=addEditUser&userId=12");
selenium.setSpeed("3000");
//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
selenium.setSpeed("1000");
....
}

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.

 

Analysts agree that a mix of emulators/simulators and real devices are necessary to optimize your mobile app testing - learn more in this white paper, brought to you in partnership with Sauce Labs.

Topics:

Opinions expressed by DZone contributors are their own.

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

{{ parent.tldr }}

{{ parent.urlSource.name }}