Commit d50c64c7 authored by Arnaud Fontaine's avatar Arnaud Fontaine

In an XPATH expression, the position is context-relative, thus fix

listboxes accordingly as the cells are either in a <thead> or <tbody>


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk/utils@44973 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent fe6d046d
...@@ -360,10 +360,20 @@ class Browser(ExtendedTestBrowser): ...@@ -360,10 +360,20 @@ class Browser(ExtendedTestBrowser):
@raise LookupError: No link could be found at the given position @raise LookupError: No link could be found at the given position
and cell indexes and cell indexes
""" """
# With XPATH, the position is context-dependent, therefore, as
# there the cells are either within a <thead> or <tbody>, the line
# number must be shifted by the number of header lines (namely 2)
if line_number <= 2:
relative_line_number = line_number
column_type = 'th'
else:
relative_line_number = line_number - 2
column_type = 'td'
xpath_str = '%s//tr[%d]//%s[%d]//a[not(contains(@class, "hidden"))][%d]' % \ xpath_str = '%s//tr[%d]//%s[%d]//a[not(contains(@class, "hidden"))][%d]' % \
(self._listbox_table_xpath_str, (self._listbox_table_xpath_str,
line_number, relative_line_number,
line_number <= 2 and 'th' or 'td', column_type,
column_number, column_number,
cell_element_index) cell_element_index)
...@@ -415,8 +425,19 @@ class Browser(ExtendedTestBrowser): ...@@ -415,8 +425,19 @@ class Browser(ExtendedTestBrowser):
column_or_line_xpath_str = "%s | %s" % (xpath_str_fmt % 'th', column_or_line_xpath_str = "%s | %s" % (xpath_str_fmt % 'th',
xpath_str_fmt % 'td') xpath_str_fmt % 'td')
else: else:
# With XPATH, the position is context-dependent, therefore, as
# there the cells are either within a <thead> or <tbody>, the
# line number must be shifted by the number of header lines
# (namely 2)
if line_number <= 2:
relative_line_number = line_number
column_type = 'th'
else:
relative_line_number = line_number - 2
column_type = 'td'
column_or_line_xpath_str = self._listbox_table_xpath_str + '//tr[%d]//%s' %\ column_or_line_xpath_str = self._listbox_table_xpath_str + '//tr[%d]//%s' %\
(line_number, line_number <= 2 and 'th' or 'td') (relative_line_number, column_type)
cell_list = self.etree.xpath(column_or_line_xpath_str) cell_list = self.etree.xpath(column_or_line_xpath_str)
...@@ -780,11 +801,18 @@ class ContextMainForm(MainForm): ...@@ -780,11 +801,18 @@ class ContextMainForm(MainForm):
@raise LookupError: No control could be found at the given @raise LookupError: No control could be found at the given
position and cell indexes position and cell indexes
""" """
if line_number <= 2:
relative_line_number = line_number
column_type = 'th'
else:
relative_line_number = line_number - 2
column_type = 'td'
xpath_str = '%s//tr[%d]//%s[%d]/*[not(@type="hidden") and ' \ xpath_str = '%s//tr[%d]//%s[%d]/*[not(@type="hidden") and ' \
'not(contains(@class, "hidden"))][%d]' % \ 'not(contains(@class, "hidden"))][%d]' % \
(self.browser._listbox_table_xpath_str, (self.browser._listbox_table_xpath_str,
line_number, relative_line_number,
(line_number <= 2 and u'th' or u'td'), column_type,
column_number, column_number,
cell_element_index) cell_element_index)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment