Re: [selenium-users] Generating a Random Email Address or Username?

3,775 views
Skip to first unread message

Oscar Rieken

unread,
Apr 27, 2013, 12:00:39 PM4/27/13
to seleniu...@googlegroups.com
My first suggestion would be to learn java.
Then I would look into creating a factory to build this random data for you.


On Thu, Apr 25, 2013 at 5:08 PM, Corey Lyons <teama...@gmail.com> wrote:
We've recently started migrating from IDE to WebDriver, and are in the process of converting many of our tests. One of these tests involves Users signing up for our site. In the past, I've used something like the following:

<tr>
<td>type</td>
<td>id=Email</td>
<td>javascript{&quot;FreeTrial&quot; + Math.floor(Math.random()*11111) + &quot;@test.com&quot;;}</td>
</tr>

To convert our tests from IDE, we're changing the format to Java / Junit4 / WebDriver. Any command we have that used this little JavaScript test is just displaying as "    // ERROR: Caught exception [ERROR: Unsupported command [getEval |  | ]]" in the converted test.

Is there a fairly easy way to generate a random string of text like this using Java?

Thanks!

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-user...@googlegroups.com.
To post to this group, send email to seleniu...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msg/selenium-users/-/_ycmunySKkkJ.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Tarun Kumar

unread,
Apr 28, 2013, 11:00:13 PM4/28/13
to seleniu...@googlegroups.com
You could add UUID to email address. For ex - 

test+UUID.randomUUID()+@gmail.com

Notice that how Gmail works, the email would always be delivered to te...@gmail.com and the part after + (UUID in our case) would be ignored.
In case you want to fetch email as well then you can use java Mail api. Don't try to automate Gmail GUI using WebDriver.


On Friday, April 26, 2013 2:38:31 AM UTC+5:30, Corey Lyons wrote:
We've recently started migrating from IDE to WebDriver, and are in the process of converting many of our tests. One of these tests involves Users signing up for our site. In the past, I've used something like the following:

<tr>
<td>type</td>
<td>id=Email</td>
<td>javascript{&quot;FreeTrial&quot; + Math.floor(Math.random()*11111) + &qu...@test.com&quot;;}</td>
</tr>

Ripon Al Wasim

unread,
Apr 29, 2013, 12:54:22 AM4/29/13
to seleniu...@googlegroups.com
Yes, it's better to use Java Mail API.  What's the problem to automate Gmail GUI using WebDriver?

br,
Ripon
skype: ripon_sky


--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-user...@googlegroups.com.
To post to this group, send email to seleniu...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msg/selenium-users/-/cc3RZfGJepYJ.

Krishnan Mahadevan

unread,
Apr 29, 2013, 4:10:13 AM4/29/13
to seleniu...@googlegroups.com
Ripon,
What exactly would one be achieving by writing UI automation tests on GMail which is extremely susceptible to changes. What would one be solving by doing it? Unless and until one is NOT working for google and primarily responsible for testing GMail there is NO reason  for anyone to write UI automation on GMail. Easier and more reliable ways such as using the Java Mail API should be the right way of dealing with this. 


--
Thanks & Regards
Krishnan Mahadevan

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"
My Scribblings @ http://wakened-cognition.blogspot.com/

Ripon Al Wasim

unread,
Apr 29, 2013, 4:18:45 AM4/29/13
to seleniu...@googlegroups.com
Thanks for your quick reply Krishnan Mahadevan. I have understood the concept.

br,
Ripon Al Wasim

David Lai

unread,
Apr 29, 2013, 8:03:53 PM4/29/13
to seleniu...@googlegroups.com
Generally the term "Factory" in the programming world deals with abstract instantiation programming patterns.  We typically call this a 'Generator' if it's generating Data.  If it also loads it into the data base, then we call it a 'Fixture'


On Saturday, April 27, 2013 9:00:39 AM UTC-7, Oscar.Rieken wrote:
My first suggestion would be to learn java.
Then I would look into creating a factory to build this random data for you.
On Thu, Apr 25, 2013 at 5:08 PM, Corey Lyons <teama...@gmail.com> wrote:
We've recently started migrating from IDE to WebDriver, and are in the process of converting many of our tests. One of these tests involves Users signing up for our site. In the past, I've used something like the following:

<tr>
<td>type</td>
<td>id=Email</td>
<td>javascript{&quot;FreeTrial&quot; + Math.floor(Math.random()*11111) + &qu...@test.com&quot;;}</td>
</tr>

Corey Lyons

unread,
May 1, 2013, 10:43:04 AM5/1/13
to seleniu...@googlegroups.com
ha, yes, learning java is definitely one of my goals!


On Saturday, April 27, 2013 11:00:39 AM UTC-5, Oscar.Rieken wrote:
My first suggestion would be to learn java.
Then I would look into creating a factory to build this random data for you.
On Thu, Apr 25, 2013 at 5:08 PM, Corey Lyons <teama...@gmail.com> wrote:
We've recently started migrating from IDE to WebDriver, and are in the process of converting many of our tests. One of these tests involves Users signing up for our site. In the past, I've used something like the following:

<tr>
<td>type</td>
<td>id=Email</td>
<td>javascript{&quot;FreeTrial&quot; + Math.floor(Math.random()*11111) + &qu...@test.com&quot;;}</td>
</tr>

Corey Lyons

unread,
Jun 4, 2013, 10:53:19 AM6/4/13
to seleniu...@googlegroups.com
found a solution that was pretty simple. i didn't need anything too complex and this is working great so far.
defined random integer:

    int ran;
    ran = 100 + (int)(Math.random() * ((10000 - 100) + 1));

entering the email address will look like this:

    driver.findElement(By.id("Email")).sendKeys("signuptest" + ran + "@test.com");

will generate something like this: signupt...@test.com
Reply all
Reply to author
Forward
0 new messages