SUM
SUM

Reputation: 1661

Selenium use regex to locate custom attribute

<button class="hbutton" h:click="app.items(client.monthlyItems)" style="">Start</button>

How do I use regex in css locator to find h:click="app.items(client.monthlyItems)" for class=hbutton?

Upvotes: 1

Views: 464

Answers (2)

JeffC
JeffC

Reputation: 25597

You just have to escape the colon (:). You can use the CSS Selector below.

"h1[h\\:click='app.items(client.monthlyItems)']"

How to use JSF generated HTML element ID with colon ":" in CSS selectors?

Upvotes: 0

Shaunak
Shaunak

Reputation: 18018

Not sure what language binding you are using, but you should be able to use xpath to find what you need. Here's an example in python: Try something like this:

driver.find_element_by_xpath("//@*[contains(., 'app.items(client.monthlyItems)')]")

You can also try a starts-with

//*[@*[starts-with(., 'app.items')]]

More details here

Upvotes: 1

Related Questions