I’m trying to use contains function on selenium and trying to do a certain action if that specific text exists and click on it.

How to use contains function with driver.find_element(). So far I tried:

testData = "Test"
if testData in element.text:
        driver.find_element(By.LINK_TEXT, contains({testData})).click() 
else:
    print(f"The element does not contain the text: {testData}.")

Support On Demand!

QA Automation