Skip to content

Commit 545d380

Browse files
committed
Update set_attribute()
1 parent 39e924a commit 545d380

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

seleniumbase/fixtures/base_case.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -738,13 +738,16 @@ def get_attribute(self, selector, attribute, by=By.CSS_SELECTOR,
738738

739739
def set_attribute(self, selector, attribute, value, by=By.CSS_SELECTOR,
740740
timeout=settings.SMALL_TIMEOUT):
741-
""" This method uses JavaScript to set/update an attribute. """
741+
""" This method uses JavaScript to set/update an attribute.
742+
Only the first matching selector from querySelector() is used. """
742743
if self.timeout_multiplier and timeout == settings.SMALL_TIMEOUT:
743744
timeout = self.__get_new_timeout(timeout)
744-
if page_utils.is_xpath_selector(selector):
745-
by = By.XPATH
745+
selector, by = self.__recalculate_selector(selector, by)
746746
if self.is_element_visible(selector, by=by):
747-
self.scroll_to(selector, by=by, timeout=timeout)
747+
try:
748+
self.scroll_to(selector, by=by, timeout=timeout)
749+
except Exception:
750+
pass
748751
attribute = re.escape(attribute)
749752
attribute = self.__escape_quotes_if_needed(attribute)
750753
value = re.escape(value)

0 commit comments

Comments
 (0)