Skip to content

Commit

Permalink
fixed a bug in bidi/session.py by removing mutable object as default …
Browse files Browse the repository at this point in the history
…value for function argument
  • Loading branch information
sandeepsuryaprasad committed Jul 20, 2024
1 parent 004746e commit f7e1885
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 12 deletions.
8 changes: 6 additions & 2 deletions py/selenium/webdriver/common/bidi/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,26 +16,30 @@
# under the License.


def session_subscribe(*events, browsing_contexts=[]):
def session_subscribe(*events, browsing_contexts=None):
cmd_dict = {
"method": "session.subscribe",
"params": {
"events": events,
},
}
if browsing_contexts is None:
browsing_contexts = []
if browsing_contexts:
cmd_dict["params"]["browsingContexts"] = browsing_contexts
_ = yield cmd_dict
return None


def session_unsubscribe(*events, browsing_contexts=[]):
def session_unsubscribe(*events, browsing_contexts=None):
cmd_dict = {
"method": "session.unsubscribe",
"params": {
"events": events,
},
}
if browsing_contexts is None:
browsing_contexts = []
if browsing_contexts:
cmd_dict["params"]["browsingContexts"] = browsing_contexts
_ = yield cmd_dict
Expand Down
30 changes: 20 additions & 10 deletions py/selenium/webdriver/support/relative_locator.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,12 @@ def __init__(self, root: Optional[Dict[ByType, str]] = None, filters: Optional[L
self.filters = filters or []

@overload
def above(self, element_or_locator: Union[WebElement, LocatorType]) -> "RelativeBy": ...
def above(self, element_or_locator: Union[WebElement, LocatorType]) -> "RelativeBy":
...

@overload
def above(self, element_or_locator: None = None) -> "NoReturn": ...
def above(self, element_or_locator: None = None) -> "NoReturn":
...

def above(self, element_or_locator: Union[WebElement, LocatorType, None] = None) -> "RelativeBy":
"""Add a filter to look for elements above.
Expand All @@ -106,10 +108,12 @@ def above(self, element_or_locator: Union[WebElement, LocatorType, None] = None)
return self

@overload
def below(self, element_or_locator: Union[WebElement, LocatorType]) -> "RelativeBy": ...
def below(self, element_or_locator: Union[WebElement, LocatorType]) -> "RelativeBy":
...

@overload
def below(self, element_or_locator: None = None) -> "NoReturn": ...
def below(self, element_or_locator: None = None) -> "NoReturn":
...

def below(self, element_or_locator: Union[WebElement, Dict, None] = None) -> "RelativeBy":
"""Add a filter to look for elements below.
Expand All @@ -124,10 +128,12 @@ def below(self, element_or_locator: Union[WebElement, Dict, None] = None) -> "Re
return self

@overload
def to_left_of(self, element_or_locator: Union[WebElement, LocatorType]) -> "RelativeBy": ...
def to_left_of(self, element_or_locator: Union[WebElement, LocatorType]) -> "RelativeBy":
...

@overload
def to_left_of(self, element_or_locator: None = None) -> "NoReturn": ...
def to_left_of(self, element_or_locator: None = None) -> "NoReturn":
...

def to_left_of(self, element_or_locator: Union[WebElement, Dict, None] = None) -> "RelativeBy":
"""Add a filter to look for elements to the left of.
Expand All @@ -142,10 +148,12 @@ def to_left_of(self, element_or_locator: Union[WebElement, Dict, None] = None) -
return self

@overload
def to_right_of(self, element_or_locator: Union[WebElement, LocatorType]) -> "RelativeBy": ...
def to_right_of(self, element_or_locator: Union[WebElement, LocatorType]) -> "RelativeBy":
...

@overload
def to_right_of(self, element_or_locator: None = None) -> "NoReturn": ...
def to_right_of(self, element_or_locator: None = None) -> "NoReturn":
...

def to_right_of(self, element_or_locator: Union[WebElement, Dict, None] = None) -> "RelativeBy":
"""Add a filter to look for elements right of.
Expand All @@ -160,10 +168,12 @@ def to_right_of(self, element_or_locator: Union[WebElement, Dict, None] = None)
return self

@overload
def near(self, element_or_locator: Union[WebElement, LocatorType], distance: int = 50) -> "RelativeBy": ...
def near(self, element_or_locator: Union[WebElement, LocatorType], distance: int = 50) -> "RelativeBy":
...

@overload
def near(self, element_or_locator: None = None, distance: int = 50) -> "NoReturn": ...
def near(self, element_or_locator: None = None, distance: int = 50) -> "NoReturn":
...

def near(self, element_or_locator: Union[WebElement, LocatorType, None] = None, distance: int = 50) -> "RelativeBy":
"""Add a filter to look for elements near.
Expand Down

0 comments on commit f7e1885

Please sign in to comment.