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

Key: WTR-237
Type: Bug Bug
Status: Closed Closed
Resolution: Duplicate
Priority: Major Major
Assignee: Unassigned
Reporter: Jeff Fry
Votes: 0
Watchers: 0
Operations

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

IE7 - focus goes to address bar after certain actions, and .focus doesn't work when focus is in address bar

Created: 12/Aug/08 07:50 PM   Updated: 13/Aug/08 06:13 PM
Component/s: HTML Controls
Affects Version/s: 1.5.6
Fix Version/s: None

Environment: IE7 Win XP.


 Description  « Hide
In IE7, certain methods, e.g. text_field.set() send focus to IE7.
This is compounded because .focus doesn't work when focus is in the address bar.

For example:
#Try to search by typing a string & hitting ENTER. (Fails)
$browser.goto("http://www.google.com")
$browser.text_field(:name, 'q').set("ruby")
$browser.send_keys("{ENTER}")
#Expected - ENTER goes to text field (and so submits form).
#Actual - After the set, focus seems to go to the address bar, and so the ENTER is sent there.

#Variation 1: Try to shift focus back after the set. (Fails)
$browser.goto("http://www.google.com")
$browser.text_field(:name, 'q').set("ruby")
#At this point, focus mysteriously moves to the address bar
$browser.text_field(:name, 'q').focus #No effect since focus is in address bar
$browser.send_keys("{ENTER}")
#Actual - Same as above - ENTER goes to address bar

Here is a workaround that does succeed:
#Variation 2: Tab to get out of address bar, then shift focus back after set. (Succeeds)
$browser.goto("http://www.google.com")
$browser.text_field(:name, 'q').set("ruby")
#At this point, focus mysteriously moves to the address bar
$browser.send_keys("{TAB}") #This takes focus away from address bar...
$browser.text_field(:name, 'q').focus #...only after which will focus work
$browser.send_keys("{ENTER}")
#Success! Enter is sent to the text field, triggering a search.

Ideally, we should figure out why focus is jumping in IE7, and stop it from doing so. If we can do that, being able to set .focus from the address bar becomes less important.



 All   Comments   Change History      Sort Order:
Jeff Fry - 13/Aug/08 06:13 PM
I'm closing this as a duplicate of WTR-197, and then updating WTR-197 with the info in this one.