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

Key: WTR-197
Type: Bug Bug
Status: Open Open
Priority: Major Major
Assignee: Unassigned
Reporter: sCrIpT mUnKeE
Votes: 1
Watchers: 2
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: 29/Jan/08 12:56 PM   Updated: 13/Aug/08 06:16 PM
Component/s: Inputs
Affects Version/s: 1.5.3
Fix Version/s: 1.6.1

Original Estimate: Unknown Remaining Estimate: Unknown Time Spent: Unknown
Environment:
IE7
Windows XP SP2 and Windows 2003 Server SP1
Watir 1.5.3 - 1.5.6
Ruby 1.8.5


 Description  « Hide
In the example below I have demonstrated that when
you use the focus method on a text_field in IE7, the actually browser
focus is not set. The field does not receive the inputed text for
"send_keys" and the "Enter" key is not registered with the "search"
button.

I first noticed this issue with the web application I am testing. Our
web application contains iFrame, but I don't think this is an issue,
and I have noticed that when the page starts the address bar of IE 7
never looses focus. It start active not matter what interactions I do
with the browser.

IE 7 Focus Example:

# starting the test
require 'watir'
ie = Watir::IE.start()
ie.goto("http://flickr.com")

# focusing the text field, because the web site does not set focus
automatically
ie.div(:id, 'featured-search').text_field(:index, 1).focus()

# adding text to the search field
ie.send_keys("{self}")
#ie.div(:id, 'featured-search').text_field(:index, 1).set("self") #
This also failes

# sending an Enter key to execute the search
ie.send_keys("{ENTER}")


 All   Comments   Work Log   Change History      Sort Order:
sCrIpT mUnKeE - 29/Jan/08 12:59 PM
Please move this bug to the proper component section.

sCrIpT mUnKeE - 31/Jan/08 11:21 AM
I performed the same test using watir 1.4.1 on my windows xp system running ruby 1.8.5-24. The test passed as expected. Then I upgraded back to 1.5.3, registered the AutoIt3x and ran the tests. The tests fail as documented above.

Jeff Fry - 13/Aug/08 06:16 PM
I've updated the summary and am adding the following notes from WTR-237 (closed as a dup):

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.