views:

223

answers:

2

I have a Selenium test case that enters dates into a date selector made up of three pulldowns (year, month, and day).

select validity_Y label=2008
select validity_M label=08
select validity_D label=08

This part gets repeated a lot throughout the test case. I'd like to reduce it by defining my custom action "selectValidity", so that I can have less redundancy, something like

selectValidity 2008,08,08

What is the best (easiest, cleanest) way to add macros or subroutines to a test case?

+3  A: 

I take it you're coding your tests in Selenese. If so, have you considered using one of the client drivers in any one of many languages? They've got java, .net, perl, ruby, javascript, php, and python. Each and every one of them have subroutines. Supposedly, the IDE can translate your existing Selenese tests into most of these.

sblundy
+3  A: 

You may be able to define your helper JS functions in a JS file and include it as a core extension or as part of user-extensions.js (as it is done for UI-Elements). A JS function called selectValidity could then use DOM to select the values.

Ates Goral
Thanks, that is what I was looking for. But I will probably move on to Selenium RC and Java, as suggested by @sblundy.
Thilo