From 409b057bdfd03f12e2215d11afbf63281c149470 Mon Sep 17 00:00:00 2001 From: Fenil Mehta <42742240+fenilgmehta@users.noreply.github.com> Date: Thu, 1 Dec 2022 20:00:25 +0530 Subject: [PATCH] =?UTF-8?q?[py]:=20=F0=9F=9A=80=20Improve=20performance=20?= =?UTF-8?q?(#11310)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Improve performance - reduce `find_element` calls * Reduce calls to `get_attribute` Co-authored-by: Simon K --- py/selenium/webdriver/support/expected_conditions.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/py/selenium/webdriver/support/expected_conditions.py b/py/selenium/webdriver/support/expected_conditions.py index c4f9a243581c5..71d9f0b841f0d 100644 --- a/py/selenium/webdriver/support/expected_conditions.py +++ b/py/selenium/webdriver/support/expected_conditions.py @@ -234,9 +234,9 @@ def text_to_be_present_in_element_attribute(locator, attribute_, text_): def _predicate(driver): try: - if not element_attribute_to_include(locator, attribute_)(driver): - return False element_text = driver.find_element(*locator).get_attribute(attribute_) + if element_text is None: + return False return text_ in element_text except StaleElementReferenceException: return False