Skip to content

[🐛 Bug]:  #10592

@tbadaud

Description

@tbadaud

What happened?

Hello,

I'm using selenium=4.1.3 with python 3.7.

I think the expected_conditions.text_to_be_present_in_element_attribute don't work the way it should.

image

In the current code, the condition L245 is useless because element_attribute_to_include always return a function.

So L247 will return None if the attribute doesn't exists and L248 will raise a TypeError: argument of type 'NoneType' is not iterable.

I think the intended behavior is :
if not element_attribute_to_include(locator, attribute_)(driver): return False

How can we reproduce the issue?

from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.expected_conditions import text_to_be_present_in_element_attribute

driver = webdriver.Chrome()
driver.get("https://google.com")

tester = text_to_be_present_in_element_attribute((By.CSS_SELECTOR, "body"), "missingattribute", "oups")
tester(driver)

Relevant log output

Traceback (most recent call last):
  File "lib\site-packages\selenium\webdriver\support\expected_conditions.py", line 248, in _predicate
    return text_ in element_text
TypeError: argument of type 'NoneType' is not iterable

Operating System

Windows 10

Selenium version

4.1.3

What are the browser(s) and version(s) where you see this issue?

Chrome 101

What are the browser driver(s) and version(s) where you see this issue?

ChromeDriver 101.0.4951.41

Are you using Selenium Grid?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-needs-triagingA Selenium member will evaluate this soon!I-defectSomething is not working as intended

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions