def set_value(self, selector, new_value, by=By.CSS_SELECTOR,<EOL>timeout=settings.LARGE_TIMEOUT):
if self.timeout_multiplier and timeout == settings.LARGE_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>orginal_selector = selector<EOL>css_selector = self.convert_to_css_selector(selector, by=by)<EOL>self.__demo_mode_highlight_if_active(orginal_selector, by)<EOL>if not self.demo_mode:<EOL><INDENT>self.scroll_to(orginal_selector, by=by, timeout=timeout)<EOL><DEDENT>value = re.escape(new_value)<EOL>value = self.__escape_quotes_if_needed(value)<EOL>css_selector = re.escape(css_selector)<EOL>css_selector = self.__escape_quotes_if_needed(css_selector)<EOL>script = ("""<STR_LIT>"""<EOL>% (css_selector, value))<EOL>self.execute_script(script)<EOL>if new_value.endswith('<STR_LIT:\n>'):<EOL><INDENT>element = self.wait_for_element_present(<EOL>orginal_selector, by=by, timeout=timeout)<EOL>element.send_keys(Keys.RETURN)<EOL>if settings.WAIT_FOR_RSC_ON_PAGE_LOADS:<EOL><INDENT>self.wait_for_ready_state_complete()<EOL><DEDENT><DEDENT>self.__demo_mode_pause_if_active()<EOL>
This method uses JavaScript to update a text field.