@@ -524,7 +524,7 @@ def wait_for_attribute(
524
524
attribute - the attribute that is expected for the element (required)
525
525
value - the attribute value that is expected (Default: None)
526
526
by - the type of selector being used (Default: By.CSS_SELECTOR)
527
- timeout - the time to wait for elements in seconds
527
+ timeout - the time to wait for the element attribute in seconds
528
528
@Returns
529
529
A web element object that contains the expected attribute/value
530
530
"""
@@ -701,6 +701,55 @@ def wait_for_text_not_visible(
701
701
timeout_exception (Exception , message )
702
702
703
703
704
+ def wait_for_attribute_not_present (
705
+ driver ,
706
+ selector ,
707
+ attribute ,
708
+ value = None ,
709
+ by = By .CSS_SELECTOR ,
710
+ timeout = settings .LARGE_TIMEOUT
711
+ ):
712
+ """
713
+ Searches for the specified element attribute by the given selector.
714
+ Returns True if the attribute isn't present on the page within the timeout.
715
+ Also returns True if the element is not present within the timeout.
716
+ Raises an exception if the attribute is still present after the timeout.
717
+ @Params
718
+ driver - the webdriver object (required)
719
+ selector - the locator for identifying the page element (required)
720
+ attribute - the element attribute (required)
721
+ value - the attribute value (Default: None)
722
+ by - the type of selector being used (Default: By.CSS_SELECTOR)
723
+ timeout - the time to wait for the element attribute in seconds
724
+ """
725
+ start_ms = time .time () * 1000.0
726
+ stop_ms = start_ms + (timeout * 1000.0 )
727
+ for x in range (int (timeout * 10 )):
728
+ s_utils .check_if_time_limit_exceeded ()
729
+ if not is_attribute_present (
730
+ driver , selector , attribute , value = value , by = by
731
+ ):
732
+ return True
733
+ now_ms = time .time () * 1000.0
734
+ if now_ms >= stop_ms :
735
+ break
736
+ time .sleep (0.1 )
737
+ plural = "s"
738
+ if timeout == 1 :
739
+ plural = ""
740
+ message = (
741
+ "Attribute {%s} of element {%s} was still present after %s second%s!"
742
+ "" % (attribute , selector , timeout , plural )
743
+ )
744
+ if value :
745
+ message = (
746
+ "Value {%s} for attribute {%s} of element {%s} was still present "
747
+ "after %s second%s!"
748
+ "" % (value , attribute , selector , timeout , plural )
749
+ )
750
+ timeout_exception (Exception , message )
751
+
752
+
704
753
def find_visible_elements (driver , selector , by = By .CSS_SELECTOR ):
705
754
"""
706
755
Finds all WebElements that match a selector and are visible.
0 commit comments