Take the 2-minute tour ×
Software Quality Assurance & Testing Stack Exchange is a question and answer site for software quality control experts, automation engineers, and software testers. It's 100% free, no registration required.

I'd like to know how you can automate the registration process for a site that requires a unique email address or username each time, using Selenium IDE. My only thought would be to insert an appropriately formatted random string into the username or email field; this could be done easily with the Python or Java version of the test case code, but what about in the initial Selenium Core syntax?

share|improve this question
add comment

3 Answers

up vote 5 down vote accepted

I normally just record all the steps then prefeace with some JS where i need it.. like...

<tr>
    <td>storeEval</td>
    <td>Math.round (Math.random() * 1357)</td>
    <td>random</td>
</tr>
<tr>
    <td>type</td>
    <td>email</td>
    <td>selenium${random}@domain.com</td>
</tr>

Works best if you have a catch-all address configured for testing @domain.com..

Quick and dirty but does the job, and points dev's in the right direction for when they compile more re-usable test cases or add it to a framework..

share|improve this answer
    
This is a good approach to things like loadtests where you will be creating a lot of accounts over the course of the test and don't want to be deleting stuff or doing any cleanup mid test (and perhaps don't care about stuff like having the email going to a real address). otherwise I'd prefer my tests cleanup after themselves and leave the system in the state they found it to start with. –  Chuck van der Linden Jun 23 '11 at 4:05
1  
Yeah, I made no comment of clean-up but would do the same. We have 'Test Harnesses' with clean data deployed for specific tests.. so in my case "Clean-up" is blow it away and start again... –  DiscoMcDisco Jun 23 '11 at 10:29
    
@Chuck I'd prefer they can do that too, but even if it passed my checks of "same state" I wouldn't consider it a viable test environment anymore. I'd insist on a clean slate for each test to ensure reproducibility. @Disco yay for clean slate test environments! –  corsiKa Jun 23 '11 at 17:21
    
@glow : exactly.. "How do you know you're testing the right thing?" ...erm, because my environment says so.. BAM! ;) –  DiscoMcDisco Jul 6 '11 at 14:48
add comment

our other option is to have some code that removes the user you created (perhaps by talking directly to the database) after the test scenario itself is complete. In a lot of frameworks it's possible to define code to run before or after each test. So for the set of tests that don't cover the 'email already in system' cases, you could have them either being sure that there is no user already in the system that uses that email, before the test runs, or removing it after.

Either one should work.

Generally I'd prefer my tests to always clean up after themselves, but sometimes it's hard to have that happen reliably.

If there's a lot of issues getting a cleanup step to run after tests that fail or something, then go for it at the start of the test.

share|improve this answer
add comment

If you want to actually receive an email (and you have a gmail account) with each test run, you can use something like this:

<tr>
  <td>runScript</td>
  <td>emailRandom=document.getElementById('email');console.log(emailRandom.value);emailRandom.value=&quot;myEmail+&quot; + Math.floor(Math.random()*11111)+ &quot;@gmail.com&quot;;</td>
 <td></td>
</tr>

This is a variation of one of the answers for Stackoverflow Question.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.