@@ -151,38 +151,33 @@ def _check_elements_displayed(
151151 if index is None :
152152 return all (e .is_displayed () == expected for e in elements )
153153 return elements [index ].is_displayed () == expected
154-
154+
155155 def is_displayed (
156- self ,
157- locator : Locator ,
158- expected : bool = True ,
159- n : int = 3 ,
160- condition : Literal ["clickable" , "visible" , "present" ] = "visible" ,
161- wait_type : Optional [WaitType ] = WaitType .DEFAULT ,
162- ** kwargs ,
156+ self ,
157+ locator : Locator ,
158+ expected : bool = True ,
159+ n : int = 3 ,
160+ condition : Literal ["clickable" , "visible" , "present" ] = "visible" ,
161+ wait_type : Optional [WaitType ] = None ,
163162 ) -> None :
164- """
165- Polls for an element to be displayed or not, and asserts the visibility.
163+ """ Checks for an element to be displayed or not, and asserts the visibility.
166164
167165 :param locator: A tuple containing the strategy and value of the element locator.
168166 :param expected: The expected visibility status of the element (True or False).
169167 :param n: The maximum number of attempts to check visibility. Defaults to 3.
170168 :param condition: The condition to wait for ("clickable", "visible", or "present").
171169 :param wait_type: The wait type to use for polling. Defaults to `WaitType.DEFAULT`.
172170
173- :raises AssertionError: If the element's visibility does not match the expected value after polling.
174- """
171+ :raises AssertionError: If the element's visibility does not match the expected value after polling."""
172+ wait_type = wait_type or WaitType . DEFAULT
175173 for _ in range (n ):
176174 try :
177- element = self .wait_for (
178- locator , condition = condition , waiter = self ._get_waiter (wait_type )
179- )
180- self ._assert_element_displayed (element , expected )
181- break
175+ element = self .wait_for (locator , condition = condition , waiter = self ._get_waiter (wait_type ))
176+ assert element .is_displayed ()== expected
177+ return
182178 except Exception :
183179 time .sleep (0.5 )
184- if _ == n - 1 :
185- assert False == expected
180+ assert False == expected
186181
187182 def is_exist (
188183 self ,
@@ -194,7 +189,7 @@ def is_exist(
194189 ** kwargs ,
195190 ) -> bool :
196191 """
197- Polls for an element's existence and checks if it meets the expected visibility status.
192+ Checks for an element's existence and checks if it meets the expected visibility status.
198193
199194 :param locator: A tuple containing the strategy and value of the element locator.
200195 :param expected: The expected existence status of the element (True or False).
0 commit comments