Skip to content

Commit

Permalink
[py] added type hints to SwitchTo class (#12296)
Browse files Browse the repository at this point in the history
* [py] added type hints to SwitchTo class

* [py] fixed lynting error
  • Loading branch information
sandeepsuryaprasad authored Jul 4, 2023
1 parent 4b9a8ea commit 6002d14
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions py/selenium/webdriver/remote/switch_to.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
# specific language governing permissions and limitations
# under the License.

from typing import Optional
from typing import Union

from selenium.common.exceptions import NoSuchElementException
from selenium.common.exceptions import NoSuchFrameException
from selenium.common.exceptions import NoSuchWindowException
Expand All @@ -26,7 +29,7 @@


class SwitchTo:
def __init__(self, driver):
def __init__(self, driver) -> None:
import weakref

self._driver = weakref.proxy(driver)
Expand Down Expand Up @@ -65,7 +68,7 @@ def default_content(self) -> None:
"""
self._driver.execute(Command.SWITCH_TO_FRAME, {"id": None})

def frame(self, frame_reference) -> None:
def frame(self, frame_reference: Union[str, int, WebElement]) -> None:
"""Switches focus to the specified frame, by index, name, or
webelement.
Expand All @@ -91,7 +94,7 @@ def frame(self, frame_reference) -> None:

self._driver.execute(Command.SWITCH_TO_FRAME, {"id": frame_reference})

def new_window(self, type_hint=None) -> None:
def new_window(self, type_hint: Optional[str] = None) -> None:
"""Switches to a new top-level browsing context.
The type hint can be one of "tab" or "window". If not specified the
Expand All @@ -116,7 +119,7 @@ def parent_frame(self) -> None:
"""
self._driver.execute(Command.SWITCH_TO_PARENT_FRAME)

def window(self, window_name) -> None:
def window(self, window_name: str) -> None:
"""Switches focus to the specified window.
:Args:
Expand All @@ -129,7 +132,7 @@ def window(self, window_name) -> None:
"""
self._w3c_window(window_name)

def _w3c_window(self, window_name):
def _w3c_window(self, window_name: str) -> None:
def send_handle(h):
self._driver.execute(Command.SWITCH_TO_WINDOW, {"handle": h})

Expand Down

0 comments on commit 6002d14

Please sign in to comment.