def set_attribute(self, selector, attribute, value, by=By.CSS_SELECTOR,<EOL>timeout=settings.SMALL_TIMEOUT):
if self.timeout_multiplier and timeout == settings.SMALL_TIMEOUT:<EOL><INDENT>timeout = self.__get_new_timeout(timeout)<EOL><DEDENT>if page_utils.is_xpath_selector(selector):<EOL><INDENT>by = By.XPATH<EOL><DEDENT>if self.is_element_visible(selector, by=by):<EOL><INDENT>self.scroll_to(selector, by=by, timeout=timeout)<EOL><DEDENT>attribute = re.escape(attribute)<EOL>attribute = self.__escape_quotes_if_needed(attribute)<EOL>value = re.escape(value)<EOL>value = self.__escape_quotes_if_needed(value)<EOL>css_selector = self.convert_to_css_selector(selector, by=by)<EOL>css_selector = re.escape(css_selector)<EOL>css_selector = self.__escape_quotes_if_needed(css_selector)<EOL>script = ("""<STR_LIT>"""<EOL>% (css_selector, attribute, value))<EOL>self.execute_script(script)<EOL>
This method uses JavaScript to set/update an attribute.