def open_url(url, is_via_js=False): """Open URL in current browser session, window, tab if this URL hasn't been opened yet and wait till the moment when web document will be fully loaded. If 'is_via_js' then use JS to perform opening. """ driver = browsers.get_driver() _login_if_needed(driver) if driver.current_url != url: if not is_via_js: driver.get(url) else: driver.execute_script("window.open('{}', '_self')".format(url)) wait_for_doc_is_ready(driver)
def open_url(url, is_via_js=False): """Open URL in current browser session, window, tab if this URL hasn't been opened yet and wait till the moment when web document will be fully loaded. If 'is_via_js' then use JS to perform opening. """ cur_url = None try: driver = browsers.get_driver() _login_if_needed(driver) cur_url = driver.current_url if cur_url != url: if not is_via_js: driver.get(url) else: driver.execute_script("window.open('{}', '_self')".format(url)) wait_for_doc_is_ready(driver) except UnexpectedAlertPresentException as exc: print "Automatically accepting alert: {0}".format(str(exc)) handle_alert(driver, accept=True)
def __init__(self, _driver=None): super(WithBrowser, self).__init__() self._driver = browsers.get_driver() self._browser = browsers.get_browser()