Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def __getitem__(self, key):
window_handles = self._browser.driver.window_handles
try:
return Window(self._browser, window_handles[key])
except TypeError:
if key not in window_handles:
raise KeyError(key)
return Window(self._browser, key)
def next(self):
""" Return the next window """
next_index = (self.index + 1) % len(self._browser.driver.window_handles)
next_handle = self._browser.driver.window_handles[next_index]
return Window(self._browser, next_handle)
def __repr__(self):
return str(
[
Window(self._browser, handle)
for handle in self._browser.driver.window_handles
]
def prev(self):
""" Return the previous window """
prev_index = self.index - 1
prev_handle = self._browser.driver.window_handles[prev_index]
return Window(self._browser, prev_handle)
def fget(self):
current_handle = self._browser.driver.current_window_handle
return Window(self._browser, current_handle) if current_handle else None
def __getitem__(self, key):
window_handles = self._browser.driver.window_handles
try:
return Window(self._browser, window_handles[key])
except TypeError:
if key not in window_handles:
raise KeyError(key)
return Window(self._browser, key)