Commit 35a20958 authored by Arnaud Fontaine's avatar Arnaud Fontaine

Allow to Browser.open() a path relative to the current context.

parent 1e81d39e
...@@ -186,24 +186,26 @@ class Browser(ExtendedTestBrowser): ...@@ -186,24 +186,26 @@ class Browser(ExtendedTestBrowser):
super(Browser, self).__init__() super(Browser, self).__init__()
def open(self, url_or_path=None, data=None): def open(self, url_or_path=None, data=None, site_relative=True):
""" """
Open a relative (to the ERP5 base URL) or absolute URL. If the Open a relative (to the ERP5 base URL) or absolute URL. If the given URL
given URL is not given, then it will open the home ERP5 page. is not given, then it will open the home ERP5 page. If C{site_relative} is
False, it will open the URL within the current context.
@param url_or_path: Relative or absolute URL @param url_or_path: Relative or absolute URL
@type url_or_path: str @type url_or_path: str
""" """
# In case url_or_path is an absolute URL, urljoin() will return if site_relative:
# it, otherwise it is a relative path and will be concatenated to # In case url_or_path is an absolute URL, urljoin() will return
# ERP5 base URL # it, otherwise it is a relative path and will be concatenated to
absolute_url = urljoin(self._erp5_base_url, url_or_path) # ERP5 base URL
url_or_path = urljoin(self._erp5_base_url, url_or_path)
if isinstance(data, dict): if isinstance(data, dict):
data = urllib.urlencode(data) data = urllib.urlencode(data)
self._logger.debug("Opening url: " + absolute_url) self._logger.debug("Opening: " + url_or_path)
super(Browser, self).open(absolute_url, data) super(Browser, self).open(url_or_path, data)
def randomSleep(self, minimum, maximum): def randomSleep(self, minimum, maximum):
""" """
......
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