Is there a way to find an element by attributes in Python Selenium?

I got an html fragment similar to this:

<input type="text" node-type="searchInput" autocomplete="off" value="" class="W_input" name="14235541231062">

The only unique property of this element in html is the attribute node-type="searchInput", so I want to find it using some Python selenium type method:

search_elem = driver.find_element_by_xxx("node-type","searchInput") # maybe?

I checked the selenium (python) document to locate the elem. but did not understand how to find this element with node-typeattr. Is there an explicit way to find this element in python selenium?

+4
source share
1 answer

You can get it by xpath and check the attribute value node-type:

driver.find_element_by_xpath('//input[@node-type="searchInput"]')
+6
source

All Articles