Musings about software development, agile methodologies, random thoughts, etc.       Bookmark and Share
Sunday, October 14, 2007 - JavaScript Functions in Selenium IDE HTML Tests
I wanted to run a JavaScript function in my Selenium IDE HTML test. Specifically, I wanted to remove any currency symbols and commas from currency values. Here is the best way that I have found to do it.

First, declare the JavaScript function.

<tr>
<td>storeEval</td>
<td>
function(input) {var output =""; output = input.replace",","");
return output.replace("$","");}
</td>
<td>replaceText</td>
</tr>

To call the replaceText function do something like this:


<tr>
<td>storeEval</td>
<td>var parsedTotal = 0; parsedTotal =
parseFloat(storedVars['replaceText']('${Amount}')).toFixed(2);
</td>
<td>parsedTotal</td>
</tr>

Now I can use the parsedTotal value later in the test:

<tr>
<td>verifyExpression</td>
<td>${parsedTotal}</td>
<td>SomeValueHere</td>
</tr>
posted by Mark McFadden @ 9:23 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