[Zope3-checkins]
SVN: Zope3/branches/benji-testbrowser-with-real-browsers-take-2/src/zope/testbrowser/real/
change the way controls are selected in the browser
Benji York
benji at zope.com
Sat Aug 19 18:13:48 EDT 2006
Log message for revision 69697:
change the way controls are selected in the browser
Changed:
U Zope3/branches/benji-testbrowser-with-real-browsers-take-2/src/zope/testbrowser/real/__resources__/commands.js
U Zope3/branches/benji-testbrowser-with-real-browsers-take-2/src/zope/testbrowser/real/real.py
-=-
Modified: Zope3/branches/benji-testbrowser-with-real-browsers-take-2/src/zope/testbrowser/real/__resources__/commands.js
===================================================================
--- Zope3/branches/benji-testbrowser-with-real-browsers-take-2/src/zope/testbrowser/real/__resources__/commands.js 2006-08-19 14:42:40 UTC (rev 69696)
+++ Zope3/branches/benji-testbrowser-with-real-browsers-take-2/src/zope/testbrowser/real/__resources__/commands.js 2006-08-19 22:13:47 UTC (rev 69697)
@@ -94,29 +94,13 @@
return id;
}
-function getElementByUniquifier(u) {
- var split = u.split(' ');
- var kind = split[0];
- var value = split[1];
- var doc = top.frames[0].document;
-
- if (kind == 'id') {
- return doc.getElementById(value);
- } else if (kind == 'form/control') {
- split = value.split('/');
- var form_number = Number(split[0]);
- var control_number = Number(split[1]);
- return doc.forms[form_number][control_number];
- } else {
- return undefined;
- }
-}
-
function _tb_setControlValue(info) {
log(info);
- var uniquifier = info[0];
- var value = info[1];
- var element = getElementByUniquifier(uniquifier);
+ var form_index = info[0];
+ var control_index = info[1];
+ var value = info[2];
+ var doc = top.frames[0].document;
+ var element = doc.forms[form_index][control_index];
element.value = value; // XXX need to handle different ways of setting value
}
Modified: Zope3/branches/benji-testbrowser-with-real-browsers-take-2/src/zope/testbrowser/real/real.py
===================================================================
--- Zope3/branches/benji-testbrowser-with-real-browsers-take-2/src/zope/testbrowser/real/real.py 2006-08-19 14:42:40 UTC (rev 69696)
+++ Zope3/branches/benji-testbrowser-with-real-browsers-take-2/src/zope/testbrowser/real/real.py 2006-08-19 22:13:47 UTC (rev 69697)
@@ -33,24 +33,30 @@
from dummymodules import interface
-def getControlUniquifier(control):
- return 'form/control 0/0'
+class BaseRealControl(object):
+ def getIndex(self):
+ for i,c in enumerate(self.mech_form.controls):
+ if self.mech_control == c:
+ return i
-class RealListControl(ListControl):
+ raise RuntimeError("couldn't find myself in my form's controls")
+
+class RealListControl(BaseRealControl, ListControl):
pass
-class RealSubmitControl(SubmitControl):
+class RealSubmitControl(BaseRealControl, SubmitControl):
pass
-class RealImageControl(ImageControl):
+class RealImageControl(BaseRealControl, ImageControl):
pass
-class RealControl(Control):
+class RealControl(BaseRealControl, Control):
@setproperty
def value(self, value):
self.browser._clear()
self.browser.executeCommand(
- 'setControlValue', getControlUniquifier(self), value)
+ 'setControlValue', self.mech_form._tb_index,
+ self.getIndex(), value)
Control.value.fset(self, value)
@getproperty
@@ -227,6 +233,11 @@
if self._forms is None:
dummy_response = DummyResponse(self.contents, self.url)
self._forms = ClientForm.ParseResponse(dummy_response)
+
+ # later we'll need to know the index of the form on the page
+ for i,f in enumerate(self._forms):
+ f._tb_index = i;
+
return self._forms
def getControl(self, label=None, name=None, index=None):
More information about the Zope3-Checkins
mailing list