Skip to content

Commit d474e2f

Browse files
committed
[py] fix typing in remote webdriver
The main change is changing the return type hint for `def get_downloadable_files(self)` from `dict` to `List[str]`, which is actually what is returned. Also some cosmetic improvements have been added.
1 parent 4df48b0 commit d474e2f

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

py/selenium/webdriver/remote/webdriver.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -372,6 +372,9 @@ def pin_script(self, script: str, script_key=None) -> ScriptKey:
372372
"""Store common javascript scripts to be executed later by a unique
373373
hashable ID.
374374
"""
375+
if not script:
376+
raise ValueError("Script must be a non-empty string")
377+
375378
script_key_instance = ScriptKey(script_key)
376379
self.pinned_scripts[script_key_instance.id] = script
377380
return script_key_instance
@@ -582,7 +585,7 @@ def get_cookies(self) -> List[dict]:
582585
"""
583586
return self.execute(Command.GET_ALL_COOKIES)["value"]
584587

585-
def get_cookie(self, name) -> Optional[Dict]:
588+
def get_cookie(self, name: str) -> Optional[Dict]:
586589
"""Get a single cookie by name. Returns the cookie if found, None if
587590
not.
588591
@@ -591,6 +594,9 @@ def get_cookie(self, name) -> Optional[Dict]:
591594
592595
driver.get_cookie('my_cookie')
593596
"""
597+
if not name:
598+
raise ValueError("Cookie name must be a non-empty string")
599+
594600
with contextlib.suppress(NoSuchCookieException):
595601
return self.execute(Command.GET_COOKIE, {"name": name})["value"]
596602
return None
@@ -1167,7 +1173,7 @@ def set_user_verified(self, verified: bool) -> None:
11671173
self.execute(Command.SET_USER_VERIFIED, {"authenticatorId": self._authenticator_id, "isUserVerified": verified})
11681174

11691175
def get_downloadable_files(self) -> List[str]:
1170-
"""Retrieves the downloadable files as a map of file names and their
1176+
"""Retrieves the downloadable files as a list of file names and their
11711177
corresponding URLs.
11721178
"""
11731179
if "se:downloadsEnabled" not in self.capabilities:

0 commit comments

Comments
 (0)