def _select_by_excludes(self, browser, excludes): for handle in browser.window_handles: if handle not in excludes: browser.switch_to.window(handle) return raise WindowNotFound('No window not matching excludes %s found.' % excludes)
def _select_by_excludes(self, excludes): for handle in self.driver.window_handles: if handle not in excludes: self.driver.switch_to.window(handle) return raise WindowNotFound("No window not matching excludes %s found." % excludes)
def _select_by_last_index(self): handles = self.driver.window_handles if handles[-1] == self.driver.current_window_handle: raise WindowNotFound( "Window with last index is same as the current window." ) self.driver.switch_to.window(handles[-1])
def _select_matching(self, browser, matcher, error): try: starting_handle = browser.current_window_handle except NoSuchWindowException: starting_handle = None for handle in browser.window_handles: browser.switch_to.window(handle) if matcher(self._get_current_window_info(browser)): return if starting_handle: browser.switch_to.window(starting_handle) raise WindowNotFound(error)
def _select_by_default(self, browser, criteria): try: starting_handle = browser.current_window_handle except NoSuchWindowException: starting_handle = None for handle in browser.window_handles: browser.switch_to.window(handle) if criteria == handle: return for item in self._get_current_window_info(browser)[2:4]: if item == criteria: return if starting_handle: browser.switch_to.window(starting_handle) raise WindowNotFound("No window matching handle, name, title or URL " "'%s' found." % criteria)
def _select_by_default(self, criteria): try: starting_handle = self.driver.current_window_handle except NoSuchWindowException: starting_handle = None for handle in self.driver.window_handles: self.driver.switch_to.window(handle) if criteria == handle: return for item in self._get_current_window_info()[2:4]: if item == criteria: return if starting_handle: self.driver.switch_to.window(starting_handle) raise WindowNotFound( f"No window matching handle, name, title or URL '{criteria}' found." )
def _select_by_last_index(self, browser): handles = browser.window_handles if handles[-1] == browser.current_window_handle: raise WindowNotFound('Window with last index is same as ' 'the current window.') browser.switch_to.window(handles[-1])