Selenium使用正则表达式定位自定义属性 开始

Selenium使用正则表达式定位自定义属性 开始,selenium,css-selectors,Selenium,Css Selectors,如何在css定位器中使用regex来查找class=hbutton的h:click=“app.items(client.monthlyItems)”?不确定您使用的是什么语言绑定,但您应该能够使用xpath来查找所需的内容。下面是python中的一个示例:尝试以下内容: <button class="hbutton" h:click="app.items(client.monthlyItems)" style="">Start</button> 您也可以尝试以 driv

如何在css定位器中使用regex来查找class=hbutton的h:click=“app.items(client.monthlyItems)”?

不确定您使用的是什么语言绑定,但您应该能够使用xpath来查找所需的内容。下面是python中的一个示例:尝试以下内容:

<button class="hbutton" h:click="app.items(client.monthlyItems)" style="">Start</button>
您也可以尝试以

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

更多详细信息

您只需退出冒号(:)。您可以使用下面的CSS选择器

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

我尝试过这个方法,但它不起作用,因为一个属性有“:”。我试图找到正则表达式来定位itOkay,我已经更新了答案,以检查包含的任何属性。看看这样行不行。。
"h1[h\\:click='app.items(client.monthlyItems)']"