예제 #1
0
 def get_new_window():
     opened_handles = set(self.driver.window_handles) - old_handles
     if len(opened_handles) != 1:
         raise WindowError("lambda passed to `window_opened_by` "
                           "opened {0} windows instead of 1".format(
                               len(opened_handles)))
     return Window(self, list(opened_handles)[0])
예제 #2
0
    def windows(self):
        """
        Get all opened windows. The order of the windows in the returned list is not defined. The
        driver may sort windows by their creation time but it's not required.

        Returns:
            List[Window]: A list of all windows.
        """

        return [Window(self, window_handle) for window_handle in self.driver.window_handles]
예제 #3
0
            def switch_and_get_matching_window():
                original_window_handle = self.driver.current_window_handle
                try:
                    for handle in self.driver.window_handles:
                        self.driver.switch_to_window(handle)
                        result = window()
                        if result:
                            return Window(self, handle)
                except Exception:
                    self.driver.switch_to_window(original_window_handle)
                    raise

                self.driver.switch_to_window(original_window_handle)
                raise WindowError("Could not find a window matching lambda")
예제 #4
0
 def current_window(self):
     """ Window: The current window. """
     return Window(self, self.driver.current_window_handle)