@@ -270,6 +270,49 @@ def is_visible(self, log=True, **kwargs) -> bool:
270270
271271 return is_visible
272272
273+ def exist (self , log = True , ** kwargs ) -> bool :
274+ """
275+ Check if element exists
276+ :param log: Boolean
277+ :return: Boolean
278+ """
279+ is_not = False
280+
281+ # Allows passing "is_not" as a kwarg to not overwrite self.__is_not.
282+ # This is not meant to be used by the user.
283+ if "is_not" in kwargs :
284+ is_not = kwargs ["is_not" ]
285+ else :
286+ is_not = self .__is_not
287+ self .__is_not = False
288+
289+ exists = False
290+ try :
291+ exists = self .get_element ()
292+
293+ if log :
294+ if exists :
295+ self .__put_log (
296+ f'{ self .device_name } : element "{ self .locator_type } : '
297+ f'{ self .locator } " exists'
298+ )
299+ else :
300+ self .__put_log (
301+ f'{ self .device_name } : element "{ self .locator_type } : '
302+ f'{ self .locator } " does not exist'
303+ )
304+ except Exception :
305+ if log :
306+ self .__put_log (
307+ f'{ self .device_name } : element "{ self .locator_type } : '
308+ f'{ self .locator } " does not exists'
309+ )
310+
311+ if is_not :
312+ return not exists
313+
314+ return exists
315+
273316 def is_visible_in (self , seconds ) -> bool :
274317 """
275318 Check if element is visible in a certain amount of time
@@ -344,6 +387,43 @@ def wait_until_visible(self, seconds=10.0, log=True):
344387 if is_not :
345388 err_text = "was"
346389
390+ self .__show_error (
391+ f"{ self .device_name } : Element { err_text } found visible with the following "
392+ f'locator: "{ self .locator_type } : { self .locator } " '
393+ f"after { time .time () - start } s"
394+ )
395+
396+ return self
397+
398+ def wait_until_exists (self , seconds = 10.0 , log = True ):
399+ """
400+ Wait until element is visible
401+ :param seconds: seconds
402+ :param log: Boolean
403+ """
404+ start = time .time ()
405+
406+ is_not = self .__is_not
407+ self .__is_not = False
408+
409+ is_visible = self .exist (log = False , is_not = is_not )
410+ while time .time () < start + seconds and not is_visible :
411+ time .sleep (0.2 )
412+ is_visible = self .exist (log = False , is_not = is_not )
413+
414+ if is_visible :
415+ if log :
416+ self .__put_log (
417+ f'{ self .device_name } : Element "{ self .locator_type } : '
418+ f'{ self .locator } " was visible in { time .time () - start } s'
419+ )
420+
421+ return self
422+
423+ err_text = "was not"
424+ if is_not :
425+ err_text = "was"
426+
347427 self .__show_error (
348428 f"{ self .device_name } : Element { err_text } found with the following "
349429 f'locator: "{ self .locator_type } : { self .locator } " '
0 commit comments