@@ -34,21 +34,17 @@ def __init__(self, driver) -> None:
3434 def active_element (self ) -> WebElement :
3535 """Returns the element with focus, or BODY if nothing has focus.
3636
37- :Usage:
38- ::
39-
40- element = driver.switch_to.active_element
37+ Example:
38+ element = driver.switch_to.active_element
4139 """
4240 return self ._driver .execute (Command .W3C_GET_ACTIVE_ELEMENT )["value" ]
4341
4442 @property
4543 def alert (self ) -> Alert :
4644 """Switches focus to an alert on the page.
4745
48- :Usage:
49- ::
50-
51- alert = driver.switch_to.alert
46+ Example:
47+ alert = driver.switch_to.alert
5248 """
5349 alert = Alert (self ._driver )
5450 _ = alert .text
@@ -57,24 +53,20 @@ def alert(self) -> Alert:
5753 def default_content (self ) -> None :
5854 """Switch focus to the default frame.
5955
60- :Usage:
61- ::
62-
63- driver.switch_to.default_content()
56+ Example:
57+ driver.switch_to.default_content()
6458 """
6559 self ._driver .execute (Command .SWITCH_TO_FRAME , {"id" : None })
6660
6761 def frame (self , frame_reference : Union [str , int , WebElement ]) -> None :
6862 """Switches focus to the specified frame, by index, name, or
6963 webelement.
7064
71- :Args:
72- - frame_reference: The name of the window to switch to, an integer representing the index,
73- or a webelement that is an (i)frame to switch to.
74-
75- :Usage:
76- ::
65+ Args:
66+ frame_reference: The name of the window to switch to, an integer representing the index,
67+ or a webelement that is an (i)frame to switch to.
7768
69+ Example:
7870 driver.switch_to.frame("frame_name")
7971 driver.switch_to.frame(1)
8072 driver.switch_to.frame(driver.find_elements(By.TAG_NAME, "iframe")[0])
@@ -96,9 +88,7 @@ def new_window(self, type_hint: Optional[str] = None) -> None:
9688 The type hint can be one of "tab" or "window". If not specified the
9789 browser will automatically select it.
9890
99- :Usage:
100- ::
101-
91+ Example:
10292 driver.switch_to.new_window("tab")
10393 """
10494 value = self ._driver .execute (Command .NEW_WINDOW , {"type" : type_hint })["value" ]
@@ -108,23 +98,19 @@ def parent_frame(self) -> None:
10898 """Switches focus to the parent context. If the current context is the
10999 top level browsing context, the context remains unchanged.
110100
111- :Usage:
112- ::
113-
101+ Example:
114102 driver.switch_to.parent_frame()
115103 """
116104 self ._driver .execute (Command .SWITCH_TO_PARENT_FRAME )
117105
118106 def window (self , window_name : str ) -> None :
119107 """Switches focus to the specified window.
120108
121- :Args:
122- - window_name: The name or window handle of the window to switch to.
123-
124- :Usage:
125- ::
109+ Args:
110+ window_name: The name or window handle of the window to switch to.
126111
127- driver.switch_to.window("main")
112+ Example:
113+ driver.switch_to.window("main")
128114 """
129115 self ._w3c_window (window_name )
130116
0 commit comments