For a long time i have talked about how important it is for Watir to make code like these examples work:

        @ie_new = Watir::IE.new
        text_field = @ie_new.text_field(:name, 'text1')
        @ie_new.goto($htmlRoot + "textfields1.html")
        assert_equal('Hello World', text_field.value)

        $ie.goto($htmlRoot + "textfields1.html")
        text_field = $ie.text_field(:name, 'text1')
        $ie.refresh
        assert_equal('Hello World', text_field.value)

Currently, these both have errors, in the first place, you get an ugly OLE error, in the second, the reference is stale and text_field.value returns an empty string. This is something that often surprises and confuses new users.

I haven't really know what to call the ability to make these examples work. For a while i called it mapping, because it allows you to create predefined window maps, if you want to, but that got Jonathan all prickly because of years he'd spent suffering from having to update SilkTest window maps.

You could also call it lazy instantiation. Not quite accurate, but it gives the right impression. Or late binding.

At the moment i think i want to call it deferred element binding, because the Watir object wouldn't actually get mapped to an element in a page until as late as possible. This would really loosen the binding between an individual Watir object and the page elements it can refer to -- and now a single Water object can in fact be used to refer to the same element on different pages or simply successive page loads (which previously all required new Watir objects). And it would also loosen the binding between Watir and COM, making it easier to support bindings to other browser driving technologies, including Selenium and XP/COM. In other words: Firefox support.

Actually, i lied. The examples above do in fact work with the latest version of Watir, found in HEAD. I just wrote the needed code tonight. Right now it only works with text boxes. And only in the simple case where it is in an IE container. But i've refactored enough of the code that the path ahead to making deferred element binding work with all elements and all containers is simply a matter of continuing the same kinds of refactorings that i've been making over the past few months anyhow. By removing duplication and reducing the size of the Watir code base, i am sure that we can get this feature working across the board.

Particular thanks go to Elisabeth Hendrickson who prodded me to prove to her that this would be hard. In the process i realized it wouldn't be quite so hard after all.

Bret


_____________________
 Bret Pettichord
 www.pettichord.com

_______________________________________________
Wtr-general mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/wtr-general

Reply via email to