History | Log In     View a printable version of the current page.  
Issue Details (XML | Word | Printable)

Key: SEL-69
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Unassigned
Reporter: David Kemp
Votes: 1
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
Selenium

Cannot handle onblur alerts that return focus to input element

Created: 09/Apr/05 11:34 PM   Updated: 15/May/05 10:09 PM
Component/s: None
Affects Version/s: 0.3
Fix Version/s: 0.4

Environment: IE6 and Firefox 1.0.2 (may not be happenning with earlier versions of Fire Fox???)


 Description  « Hide
Testing a page with an input element like this:

<input name="testInput" onblur="javascript:generateAnAlertAndFocus(this);" />

<script type="text/javascript">
function generateAnAlertAndFocus(inputElement) {
if (inputElement.value == "test") { alert("Bad value"); inputElement.focus(); }
}
</script>

Using the following Selenium test:

<tr>
<td>type</td>
<td>testInput</td>
<td>test</td>

</tr>
<tr>
<td>verifyAlert</td>
<td>Bad value</td>
<td></td>
</tr>

<tr>
<td>type</td>
<td>testInput</td>
<td>somethingelse</td>
</tr>

Selenium fails on the last command with a complaint that there was an unverified alert even though it was verified on the previous command. I know the trick of returning focus to the input element is not portable, but the project that I am currently on has been using this trick quite heavily (only targetting IE... sigh...).

I can only guess that the problem might be that the onblur event handler is being called again when the Fit runner focusses on the next command to estimated.



 All   Comments   Change History      Sort Order:
David Kemp - 17/Apr/05 04:47 PM
The problem seems to be the call to focusOnElement in the commandStarted() method of selenium-fitrunner.js

At Mike William's suggestion I tried scrollIntoView() and that seems to solve the problem. I added the following code to the start of focusOnElement:

if (element.scrollIntoView) { element.scrollIntoView(); return; }

Also, given that focusOnElement is only called from within commandStarted() and its purpose is to scroll the element into view, perhaps the function should be renamed to scrollIntoView.


Darrell DeBoer - 15/May/05 10:09 PM
Fixed in r517. Thanks to David Kemp.