jgord080
jgord080

Reputation: 9

Python Selenium find placeholder if it contains

At the moment my code is

driver.find_element_by_xpath("//input[@placeholder='phone']").send_keys('000000000000') 

How would I make it so it would find the placeholder if it contained the word "phone", not just finding the exact word like it is at the moment?

Thanks

Upvotes: 0

Views: 73

Answers (1)

ScottC
ScottC

Reputation: 4105

You can use the contains() function to check if the placeholder attribute contains the word "phone":

Code:

driver.find_element_by_xpath("//input[contains(@placeholder, 'phone')]").send_keys('000000000000')

This will find any input elements with a placeholder attribute that contains the word "phone", rather than just matching the exact string "phone".

Upvotes: 1

Related Questions