@@ -812,6 +812,25 @@ def remove_attribute(self, selector, attribute, by=By.CSS_SELECTOR,
812
812
% (css_selector , attribute ))
813
813
self .execute_script (script )
814
814
815
+ def remove_attributes (self , selector , attribute , by = By .CSS_SELECTOR ):
816
+ """ This method uses JavaScript to remove a common attribute.
817
+ All matching selectors from querySelectorAll() are used. """
818
+ selector , by = self .__recalculate_selector (selector , by )
819
+ attribute = re .escape (attribute )
820
+ attribute = self .__escape_quotes_if_needed (attribute )
821
+ css_selector = self .convert_to_css_selector (selector , by = by )
822
+ css_selector = re .escape (css_selector )
823
+ css_selector = self .__escape_quotes_if_needed (css_selector )
824
+ script = ("""var $elements = document.querySelectorAll('%s');
825
+ var index = 0, length = $elements.length;
826
+ for(; index < length; index++){
827
+ $elements[index].removeAttribute('%s');}"""
828
+ % (css_selector , attribute ))
829
+ try :
830
+ self .execute_script (script )
831
+ except Exception :
832
+ pass
833
+
815
834
def get_property_value (self , selector , property , by = By .CSS_SELECTOR ,
816
835
timeout = settings .SMALL_TIMEOUT ):
817
836
""" Returns the property value of a page element's computed style.
0 commit comments