2015-02-10 117 views
4

我有一个HTML片段是这样的:有没有办法在Python Selenium中按属性查找元素?

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

在HTML该元素的唯一的唯一身份是属性node-type="searchInput",所以我想用Python中硒的一些方法有点像找到它这样的:

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

我已经检查了硒(蟒蛇)document for locating elems,但没有得到如何通过node-type ATTR找到此ELEM线索。有没有明确的方法来找到这个元素在蟒蛇硒?

回答

6

你可以得到它与XPath并检查node-type属性值:

driver.find_element_by_xpath('//input[@node-type="searchInput"]') 
相关问题