[Erp5-report] r8415 - /erp5/trunk/utils/erp5mechanize/ERP5Mechanize.py
nobody at svn.erp5.org
nobody at svn.erp5.org
Tue Jul 11 17:58:10 CEST 2006
Author: vincent
Date: Tue Jul 11 17:58:08 2006
New Revision: 8415
URL: http://svn.erp5.org?rev=8415&view=rev
Log:
Initial support of listbox browsing. Requires minidom python library.
Modified:
erp5/trunk/utils/erp5mechanize/ERP5Mechanize.py
Modified: erp5/trunk/utils/erp5mechanize/ERP5Mechanize.py
URL: http://svn.erp5.org/erp5/trunk/utils/erp5mechanize/ERP5Mechanize.py?rev=8415&r1=8414&r2=8415&view=diff
==============================================================================
--- erp5/trunk/utils/erp5mechanize/ERP5Mechanize.py (original)
+++ erp5/trunk/utils/erp5mechanize/ERP5Mechanize.py Tue Jul 11 17:58:08 2006
@@ -326,7 +326,56 @@
Fails if the tab is not present.
"""
return self.doAction(link_target=value)
-
+
+ def _getListbox(self):
+ """
+ Returns a dom element that is the div containing listbox content.
+ 'Content' includes : data lines, stat lines, title lines.
+
+ XXX: what if there is more than one listbox in a page ?
+ """
+ from xml.dom.minidom import parseString
+ document = parseString(self.getHtml().get_data())
+ for element in document.getElementsByTagName('div'):
+ if element.attributes.get('class').value == u'ListContent': # Hardcoded class name
+ return element
+ return None
+
+ def fillListboxField(self, line_number, column_number, value):
+ """
+ Fills the editable field located at given coordinates (starts at indice 0) in listbox with given value.
+ Raises an exception if there is no editable field at given position.
+
+ XXX: what if there is more than one field in a cell ?
+ """
+ input = self._getListbox().getElementsByTagName('tr')[line_number]\
+ .getElementsByTagName('td')[column_number]\
+ .getElementsByTagName('input')[0]
+ if input.attributes.get('type').value.lower() != u'hidden' and not input.attributes.has_key(u'disabled'):
+ input['value'] = value
+
+ def getListboxRow(self, column_number, value, strict=False):
+ """
+ Returns the number of the first line containing given text in given column, None if not found.
+ """
+ line_list = self._getListbox().getElementsByTagName('tr')
+ for line_pos in xrange(len(line_list)):
+ for child in line_list[line_pos].getElementsByTagName('td')[column_number].childNodes:
+ if (child.nodeType == child.TEXT_NODE) and strict and (value == child.wholeText) or (value in child.wholeText):
+ return line_pos
+ return None
+
+ def getListboxColumn(self, line_number, value, strict=False):
+ """
+ Returns the number of the first column containing given text at given line, None if not found.
+ """
+ column_list = self._getListbox().getElementsByTagName('tr')[line_number].getElementsByTagName('td')
+ for cell_pos in xrange(len(column_list)):
+ for child in column_list[cell_pos].childNodes:
+ if (child.nodeType == child.TEXT_NODE) and strict and (value == child.wholeText) or (value in child.wholeText):
+ return line_pos
+ return None
+
class TimeResult:
"""
Contains details about a tests execution :
More information about the Erp5-report
mailing list