Commit d59d42f3 authored by Arnaud Fontaine's avatar Arnaud Fontaine

Raise a LookupError when either a listbox link or control could not be

found within the given cell


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk/utils@44856 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 042f8589
......@@ -337,8 +337,19 @@ class Browser(ExtendedTestBrowser):
column_number,
cell_element_index)
return self.getContextLink(url=self.etree.xpath(xpath_str).get('href'),
*args, **kwargs)
# xpath() method always return a list even if there is only one element
element_list = self.etree.xpath(xpath_str)
try:
link_href = element_list[0].get('href')
except (IndexError, AttributeError):
link_href = None
if not link_href:
raise LookupError("Could not find link in listbox cell %dx%d (index=%d)" %\
(line_number, column_number, cell_element_index))
return self.getContextLink(url=link_href, *args, **kwargs)
def getListboxPosition(self,
text,
......@@ -700,7 +711,18 @@ class ContextMainForm(MainForm):
column_number,
cell_element_index)
input_element = self.browser.etree.xpath(xpath_str)[0]
# xpath() method always return a list even if there is only one element
element_list = self.browser.etree.xpath(xpath_str)
try:
input_element = element_list[0]
input_name = input_element.get('name')
except (IndexError, AttributeError):
input_element = input_name = None
if input_element is None or not input_name:
raise LookupError("Could not find control in listbox cell %dx%d (index=%d)" %\
(line_number, column_number, cell_element_index))
control = self.getControl(name=input_element.get('name'), *args, **kwargs)
......
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