Skip to content

Instantly share code, notes, and snippets.

@m2web
Created July 22, 2013 21:53
Show Gist options
  • Save m2web/6058068 to your computer and use it in GitHub Desktop.
Save m2web/6058068 to your computer and use it in GitHub Desktop.
Example Selenium HTML Test Code for Selenium IDE
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Test</title>
</head>
<body>
<table cellpadding="1" cellspacing="1" border="1">
<tr>
<td>type</td>
<td>j_username</td>
<td>UserNameHere</td>
</tr>
<tr>
<td>type</td>
<td>j_password</td>
<td>PasswordHere</td>
</tr>
<tr>
<td>clickAndWait</td>
<td>submit_logon</td>
<td></td>
<tr>
<td>storeEval</td>
<td>function(input) {var output = ""; output = input.replace(",",""); return output.replace("$","");}</td>
<td>replaceText</td>
</tr>
<tr>
<td>storeEval</td>
<td>var theRows = selenium.browserbot.getCurrentWindow().document.getElementById("resultsTable").rows; var rowCount = selenium.browserbot.getCurrentWindow().document.getElementById('resultsTable').rows.length; var totalAmount = 0; for(i = 1; i &lt; rowCount; i++){ totalAmount += parseFloat(storedVars['replaceText'](theRows[i].cells[8].innerHTML));}</td>
<td>totalAmount</td>
</tr>
<tr>
<td>storeEval</td>
<td>var parsedTotalAmount = 0; parsedTotalAmount = (${totalAmount}).toFixed(2);</td>
<td>parsedTotalAmount</td>
</tr>
<tr>
<td>storeEval</td>
<td>var parsedTotal = 0; parsedTotal = parseFloat(storedVars['replaceText']('${Amount}')).toFixed(2);</td>
<td>parsedTotal</td>
</tr>
<tr>
<td>verifyExpression</td>
<td>${parsedTotal}</td>
<td>${parsedTotalAmount}</td>
</tr>
</tbody></table>
</body>
</html>
@sonym
Copy link

sonym commented Jul 23, 2013

so this code is not working for me. so the thing i am trying to verify in selenium ide is i have a variable a =1234, i have another variable b=1,234 and i want to verify that a = b and i am trying to use replace function to replace comma with nothing/blank and verify that a = b

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment