This method uses JavaScript to set/update an attribute.

def set_attribute(self, selector, attribute, value, by=By.CSS_SELECTOR,
                      timeout=settings.SMALL_TIMEOUT):
        """ This method uses JavaScript to set/update an attribute. """
        if self.timeout_multiplier and timeout == settings.SMALL_TIMEOUT:
            timeout = self.__get_new_timeout(timeout)
        if page_utils.is_xpath_selector(selector):
            by = By.XPATH
        if self.is_element_visible(selector, by=by):
            self.scroll_to(selector, by=by, timeout=timeout)
        attribute = re.escape(attribute)
        attribute = self.__escape_quotes_if_needed(attribute)
        value = re.escape(value)
        value = self.__escape_quotes_if_needed(value)
        css_selector = self.convert_to_css_selector(selector, by=by)
        css_selector = re.escape(css_selector)
        css_selector = self.__escape_quotes_if_needed(css_selector)
        script = ("""document.querySelector('%s').setAttribute('%s','%s');"""
                  % (css_selector, attribute, value))
        self.execute_script(script)