user2661518
user2661518

Reputation: 2755

Find element via other than id, class name, etc

I have HTML like this

<img src="/image.png" value="-" alt="collapse">

I can get element like this:

driver.find_element_by_xpath('//img')

I see I can also get name by id or class_name. But can I get an element by other names e.g. src or value? I want to run a test only if value is -.

Upvotes: 2

Views: 425

Answers (1)

kjhughes
kjhughes

Reputation: 111786

The following XPath will select all img elements with a value attribute equal to -:

//img[@value='-']

Upvotes: 3

Related Questions