Skip to content

Commit

Permalink
Use property decorator instead of class (#1243)
Browse files Browse the repository at this point in the history
  • Loading branch information
jsfehler committed Feb 15, 2024
1 parent a013448 commit f14d20e
Showing 1 changed file with 10 additions and 15 deletions.
25 changes: 10 additions & 15 deletions splinter/driver/webdriver/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,7 @@ def __repr__(self):


class Windows:

"""A class representing all open browser windows"""
"""Representation of all open browser windows."""

def __init__(self, browser):
self._browser = browser
Expand All @@ -185,19 +184,15 @@ def __getitem__(self, key):
raise KeyError(key)
return Window(self._browser, key)

def current():
doc = "The currently active window"

def fget(self):
current_handle = self._browser.driver.current_window_handle
return Window(self._browser, current_handle) if current_handle else None

def fset(self, value):
self._browser.driver.switch_to.window(value.name)

return locals()

current = property(**current())
@property
def current(self):
"""The currently active window"""
current_handle = self._browser.driver.current_window_handle
return Window(self._browser, current_handle) if current_handle else None

@current.setter
def current(self, new_value):
self._browser.driver.switch_to.window(new_value.name)

def __repr__(self):
return str(
Expand Down

0 comments on commit f14d20e

Please sign in to comment.