Hi, Yes, the browser window movements, max, min, restore, bring_to_front rely on the DOM title. The way IE behaves is it displays the location in the title bar if 'title' tag is empty or does not exist.
I have the following extension in Watirloo for dealing with windows in my tests The code handles 4 cases 1) When title exists then just display title (default) 2) When IE displays inbrowser PDF for example then title does not exist so the title is the http://url 3) When title is blank and IE displays document from local drive (NOT http) then locationUrl is a "file://c:/data.html" representaion but the title is "c:\data.html" 4) When title is blank and IE displays from server then then Window displays http:// location. Here is the code http://gist.github.com/141738 and the short version # Provides the Title of the IE Window # which may not equal to <title> DOM value # When <title></title> is empty OR does not exist in the DOM # (for example when PDF is displayed in browser) # Then return title_from_url string visible in the window # Else return <title> DOM value def title mytitle = begin @ie.document.title rescue WIN32OLERuntimeError => e #unknown property 'title' log "WIN32OLERuntimeError: #{e}" "" #return empty string for title value empty end (mytitle == "")? title_from_url : mytitle end # When I have a file loaded in browser serverd by file system in location "c:\data\file.html" # And the title tag is empty "" # Then url method returns file:/// format "file:///c:/data/file.html" # But the window title displays "c:\data\file.html" # this method massages the locationUrl and returns its representation in title bar def title_from_url loc = url # relies on IE.url to return @ie.locationUrl and not @ie.document.url (loc[0,8] == "file:///") ? loc.split("file:///")[1].gsub("/", '\\') : loc end Sorry, it's not on github yet and it's not part of Watir becasue I don't have all the tests loaded. It was hacked for specifi purpose of dealing with inbrowser PDF loading where I need to bring_to_front and save PDF locally using AutoIt. hope this helps someone. marekj Watirloo: Semantic Page Objects in UseCases http://github.com/marekj/watirloo/ On Wed, Jul 1, 2009 at 4:33 AM, ricardo fernandes<[email protected]> wrote: > > Hello. > > I found a bug on these functions minimize, restore and maximize. > To replicate this error is very simple, create a page with no > title or with a empty title. > When this happen IE put the url is the window title. > Then when we try to use one of these functions(minimize, restore > and maximize) > watir will call the function set_window_state in autoit using the > title(code from ie-class): > > def set_window_state(state) > autoit.WinSetState title, '', autoit.send(state) > end > > but because the title is empty autoit will not find the window > because the window > title is the url and will not do nothing. > > I resolved this issue by changing the function title in ie-class > to this: > > def title > if(@ie.document.title=="") > return @ie.document.url > else > return @ie.document.title > end > end > > Watir code: > > require 'test/unit' > require 'watir' > > class WebTest < Test::Unit::TestCase > > def setup > �...@browser = Watir::IE.new > �[email protected]("http://localhost/FunFxTests/index2.html") > end > > def teardown > �[email protected] > end > > def go_to_page > �[email protected]() > �[email protected]() > �[email protected]() > end > > def test_control > go_to_page > end > end > > Html Code: > <html> > <title></title> > <frameset cols="50%,50%" title="titulo1" text="texto2" > > <frame src="index2.htm" style="display:none; visibility:hidden"> > <frame src="index3.htm"> > </frameset> > </html> > > > > > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Watir General" group. To post to this group, send email to [email protected] Before posting, please read the following guidelines: http://wiki.openqa.org/display/WTR/Support To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/watir-general -~----------~----~----~----~------~----~------~--~---
