Recently I need to populate my new Drupal site with some new registered users. For this I used a selenium script. Here goes the script.

drupal_test
getEval array=new Array(2);
getEval index=0;
store javascript{array.length} x
gotoIf ${x}>19 target_2
while index<array.length
label target_1
open /drupal-7.14/?q=user/register
randomText id=edit-name
randomEmail id=edit-mail
type id=edit-field-age-und-0-value 24
type id=edit-field-first-name-und-0-value Jack
type id=edit-field-last-name-und-0-value sparrow
type id=edit-field-sex-und-0-value Male
clickAndWait id=edit-submit
waitForText css=div.messages.status Status message Thank you for applying for an account. Your account is currently pending approval by the site administrator.
In the meantime, a welcome message with further instructions has been sent to your e-mail address.
verifyTextPresent Status message Thank you for applying for an account. Your account is currently pending approval by the site administrator.
In the meantime, a welcome message with further instructions has been sent to your e-mail address.
getEval index++;
endWhile
label target_2
echo Either completed or you attempted to create more then 20 user accorunt, are you sure? To continue change the value in line 5.

Here I used two custom commands: “randomText” and “randomEmail”. You can find the detail of this two custom command Here.

Customization:

  • In this script I use a limit, for this maximum 19 users can create using this script. One can change the limit easily by customizing line number 4.
P.S: The code is open and used for learning purpose only. If anyone use this code for any abusive purpose that would be his/her own responsibilities.
Advertisements