How can I automate clicking this anchor tag with Selenium IDE (in Mozilla Firefox of course)? I tried two different approaches, and neither one worked. Would it matter that this is in a popup window? I can get other controls to work.
HTML:
<a href=”javascript:__doPostBack(‘EditTestResult$EditOverallTestResults$BucketMove$LBuSelect’,”)” class=”standard-text” id=”EditTestResult_EditOverallTestResults_BucketMove_LBuSelect”>-></a>
Selenium Code that didn’t work:
Command: clickAndWait
Target: id=EditTestResult_EditOverallTestResults_BucketMove_LBuSelect
Value:
Selenium Code that didn’t work:
Command: clickAndWait
Target: link=->
Value:
==========================
8/7/2011 update
So I got more information on this one. The command before this command is the following:
Command: addSelection
Target: id=idofmultiselect
Value: option1
When I start the script (keypress of “s”) on my “clickAndWait” command above, it works fine (for both versions). It’s when I have this multi-select selection when the IDE gets STUCK on the clickAndWait command. I’ve tried using “addSelectionAndWait” and that didn’t fix it.
==========================
8/8/2011 update
I can’t put the actual dynamic code in, so this will have to suffice.
<html>
<body>
<form>
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td><span id="EditTestResult_EditOverallTestResults_BucketMove_LblUnselectedBox">Does Not Have Results...</span><br>
<select size="4" name="EditTestResult$EditOverallTestResults$BucketMove$LBoUnselected" multiple="multiple" id="EditTestResult_EditOverallTestResults_BucketMove_LBoUnselected" style="height:100px;width:220px;">
<option value="214">Cocaine/Metabolite - Positive</option>
<option value="213">Opiate - Positive</option>
<option value="37">Phencyclidine - Positive</option>
<option value="58">THC Metabolite - Positive</option>
</select></td>
<td vAlign="middle">
<table>
<tr>
<td><a id="EditTestResult_EditOverallTestResults_BucketMove_LBuSelect" class="standard-text" href="javascript:__doPostBack('EditTestResult$EditOverallTestResults$BucketMove$LBuSelect','')">-></a></td>
</tr>
<tr>
<td><a id="EditTestResult_EditOverallTestResults_BucketMove_LBuUnselect" class="standard-text" href="javascript:__doPostBack('EditTestResult$EditOverallTestResults$BucketMove$LBuUnselect','')"><-</a></td>
</tr>
</table>
</td>
<td><span id="EditTestResult_EditOverallTestResults_BucketMove_LblSelectedBox">Has Results...</span><br>
<select size="4" name="EditTestResult$EditOverallTestResults$BucketMove$LBoSelected" multiple="multiple" id="EditTestResult_EditOverallTestResults_BucketMove_LBoSelected" style="height:100px;width:220px;">
<option value="206">Amphetamine - Positive</option>
</select></td>
</tr>
</table>
<script type="text/javascript">
//<![CDATA[
var theForm = document.forms['Form1'];
if (!theForm) {
theForm = document.Form1;
}
function __doPostBack(eventTarget, eventArgument) {
alert("doing postback");
if (!theForm.onsubmit || (theForm.onsubmit() != false)) {
theForm.__EVENTTARGET.value = eventTarget;
theForm.__EVENTARGUMENT.value = eventArgument;
theForm.submit();
}
}
//]]>
</script>
</form>
</body>
</html>
====================
8/22/2011 update:
Discovered that ASP.NET validation can cause the clickAndWait command to implicitly fail. When running the script in Selenium, validation messages in the Selenium IDE don’t show like they do when using a web browser manually. So it may appear that the command fails, but in reality, the form couldn’t submit and you can’t see the red validation messages in the browser like you normally can when you manually click a button with your mouse (rather than having the clickAndWait command doing it). That fixed a bunch of my issues, but not this one. I’m still looking for an answer.
The problem here is likely a synchronization one. If this is an AJAX, which it appears to be, then all the AndWait methods are useless to you.
Try just using Click followed by WaitForElementPresent or something similar.
AndWait will only work when there is a complete, physical page load in the browser. This looks like it is part of a much larger form and I would be surprised if that is happening given the code you provided.
See also http://saucelabs.com/blog/index.php/2011/02/advanced-selenium-synchronization-with-latches/