Musings about software development, agile methodologies, random thoughts, etc.       Bookmark and Share
Wednesday, May 09, 2007 - The Selenium storEval Method in Action
I was creating Selenium tests for the module on a J2EE app at work and noted that the requirements wanted the beginning and end dates in the search text boxes to be the current date. I then thought, "Hmmm, these tests will be run on various dates. How can I get the current date to validate that the current date, in a specified format, is entered into the beginning and end date textbox entries for a search query?"

A little digging on the OpenQA site in the reference for Selenium and I found the storEval method. According to the reference this method, "Gets the result of evaluating the specified JavaScript snippet. The snippet may have multiple lines, but only the result of the last line will be returned." That was just what I needed.

Here is where the method is used in the test that is stored in an HTML file:

<tr>
<td>storeEval</td>
<td>var d = new Date(); var mday = d.getDate();
var mmonth = d.getMonth() + 1; var myear; if (navigator.appName == 'Microsoft
Internet Explorer') {myear = d.getYear();} else {myear = d.getYear() + 1900;}
if (mday.toString().length == 1) { mday = '0' + mday; } if
(mmonth.toString().length == 1) { mmonth = '0' + mmonth; } todaysDate = mmonth
+ '/' + mday + '/' + myear;</td>
<td>todaysDate</td>
</tr>
<tr>

Note that the todaysDate variable above is passed the formatted current date. I then use it later in the test to assert that this is what is entered into the beginning and end date text boxes.

<tr>
<td>verifyValue</td>
<td>searchBeginDate</td>
<td>${todaysDate}</td>
</tr>
<tr>
<td>verifyValue</td>
<td>searchEndDate</td>
<td>${todaysDate}</td>
</tr>

Labels: , , , , , , ,

posted by Mark McFadden @ 8:15 PM   0 comments
0 Comments:
<< Home
 
Saturday, March 24, 2007 - Ubuntu Desktop in Microsoft's Virtual PC 2007
I pulled down Microsoft's VPC 2007, which is free, a few weeks ago and have been using it on my Windows XP workstation and laptop. I even have a VPC machine with Vista and Office 2007.

I setup the VPC machine with Vista and then created a copy of the VPC to test drive. This enables me to play with it, and even break it with no issues. If I mess it up I just make another copy of my master VPC and go at it again. This is great for development and testing.

I even got the Ubuntu Desktop on a VPC machine thanks to a blog post from Arcane entitled Installing Ubuntu 6.10 on Virtual PC 2007 Step by Step.

Labels: , , , , ,

posted by Mark McFadden @ 7:28 PM   0 comments
0 Comments:
<< Home
 

My Photo
Name: Mark McFadden
Location: Erlanger, Kentucky

I am a software developer that lives in Northern Kentucky with my wonderful wife.


This work is licensed under a Creative Commons Attribution 3.0 United States License. Creative Commons License

Site Feed

Previous Posts

Archives