[Zope-dev] Strange zc.testbrowser.real issues (javascript problem)
Hi, I've been developing tutorialtest ( http://grahamstratton.org/straightornamental/entries/z3ctutorialtest ), and hit on a couple of issues with zc.testbrowser.real. These may be Firefox bugs, but I know very little about DOM stuff, and my Javascript books are 11,000 miles away. My web application allows the user to toggle the visibility of some forms. I found that setting the value of form elements in forms that had at one point been hidden failed. It turns out that setAttribute('value', ...) stops working, as shown in the REPL session below. Initally it's possible to set values quite happily (note that element.value consistently gives the value that is displayed and submitted. element.getAttribute(value) consistently gives the value set with setAttribute; the problem is when these differ): repl> content .document.getElementById('form.name').setAttribute('value','three') repl> content.document.getElementById('form.name').value "three" repl> content .document.getElementById('form.name').setAttribute('value','four') repl> content.document.getElementById('form.name').value "four" Now if we hide and show the element (or any enclosing element), setAttribute stops working: repl> content.document.getElementById('form.name').style.display "" repl> content.document.getElementById('form.name').style.display = 'none' "none" repl> content.document.getElementById('form.name').style.display = '' "" repl> content .document.getElementById('form.name').setAttribute('value','three') repl> content.document.getElementById('form.name').value "four" I edited real.py to read and write the property directly rather than using (s/g)etAttribute for all elements except file controls. After that, all the tests still pass. I suspect this is not good practice, but it makes it work. Should I check in this patch, or is there a better fix? Many thanks, Graham Patch against MozLab 0.1.9 branch of zc.testbrowser: Index: src/zc/testbrowser/real.py === --- src/zc/testbrowser/real.py (revision 88569) +++ src/zc/testbrowser/real.py (working copy) @@ -399,7 +399,7 @@ def value(): def fget(self): -if self.type == 'textarea': +if self.type != 'file': return self.browser.execute('tb_tokens[%s].value' % self.token) return self.browser.execute( @@ -419,7 +419,7 @@ self.mech_control.items[0].selected = bool(value) else: self.browser.execute( -'tb_tokens[%s].setAttribute("value", %s)' %( +'tb_tokens[%s].value = %s' %( self.token, simplejson.dumps(value))) return property(fget, fset) ___ Zope-Dev maillist - Zope-Dev@zope.org http://mail.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope )
Re: [Zope-dev] Re: zc.testbrowser.real support for mozlab 0.1.9
On 4 Jul 2008, at 17:34, Christian Zagrodnick wrote: On 2008-07-04 01:19:47 +0200, Graham Stratton <[EMAIL PROTECTED] beasts.com> said: I tried running the tests with Python 2.4. About half the time they pass fine, and the other half fail something like this: File "", line 1, in ? browser.open('navigate.html') File "/Users/graham/development/patched_zc.testbrowser/src/ zc/ testbrowser/real.py", line 201, in open self.wait() File "/Users/graham/development/patched_zc.testbrowser/src/ zc/ testbrowser/real.py", line 193, in wait assert self.execute('tb_page_loaded;') == 'false' AssertionError though for varying pages with browser.open(). I don't understand what could be causing it; why would that value be changed in between those two lines? I guess the time.sleep() on line 191 implies that there's something we might want to wait for. I increased it by 10x and only got 1 failure out of 10, so I guess that helps. I had this error, too and checked in a maybe-fix in r87964. Have you tried with this revision or the one before? If it's thisone I'll add another loop there. I've tried with this revision, and with the timeout extended, but still occasionally see the problem. I have a couple of independent fixes for other issues which I'll discuss once this branch is merged. Regards, Graham ___ Zope-Dev maillist - Zope-Dev@zope.org http://mail.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope )
Re: [Zope-dev] zc.testbrowser.real support for mozlab 0.1.9
I've checked in a branch with changes to the testbrowser.real code to make it work with mozlab 0.1.9 (and firefox 3). Hi Sebastian, This is great. I spent all day yesterday trying to make this happen and didn't get anywhere. Sometimes I wake up with a better idea as to how to solve things, but I don't often wake up to find all the work's been done! I tried running the tests with Python 2.4. About half the time they pass fine, and the other half fail something like this: File "", line 1, in ? browser.open('navigate.html') File "/Users/graham/development/patched_zc.testbrowser/src/zc/ testbrowser/real.py", line 201, in open self.wait() File "/Users/graham/development/patched_zc.testbrowser/src/zc/ testbrowser/real.py", line 193, in wait assert self.execute('tb_page_loaded;') == 'false' AssertionError though for varying pages with browser.open(). I don't understand what could be causing it; why would that value be changed in between those two lines? I guess the time.sleep() on line 191 implies that there's something we might want to wait for. I increased it by 10x and only got 1 failure out of 10, so I guess that helps. Thanks, Graham ___ Zope-Dev maillist - Zope-Dev@zope.org http://mail.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope )
[Zope-dev] TutorialTest with zc.testbrowser.real
Hi all, I currently need to write a tutorial for how to use the web application which I've been developing. I'd really like to be able to produce something testable, in a doctest-like way. My best idea so far is to build something based on zc.testbrowser.real, incorporating the ability to display comments on the screen and to pause for some amount of time/until the user clicks the mouse. The tutorial would need to run as a standard test (using zc.testbrowser.browser?) when run from the test runner, but in human- friendly mode when run as a tutorial. I'm guessing that something like this would be very useful to many people; so much so that I'd expect something similar to have been done before. Is this the case? I have concerns about getting the tutorial to run against an existing ZODB without making modifications to it. I think there's some kind of storage which can wrap an existing storage, can anyone point me the right way? I think Stephan and others had some ideas along these lines at the Foliage Sprint. I'd be grateful for your thoughts before I get started. Thanks, Graham ___ Zope-Dev maillist - Zope-Dev@zope.org http://mail.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope )