<button class="hbutton" h:click="app.items(client.monthlyItems)" style="">Start</button>
如何使用正則表達式在css定位器中找到h = click =「app.items(client.monthlyItems)」class = hbutton?硒使用正則表達式來定位自定義屬性
<button class="hbutton" h:click="app.items(client.monthlyItems)" style="">Start</button>
如何使用正則表達式在css定位器中找到h = click =「app.items(client.monthlyItems)」class = hbutton?硒使用正則表達式來定位自定義屬性
你只需要逃避冒號(:)。您可以使用下面的CSS選擇器。
"h1[h\\:click='app.items(client.monthlyItems)']"
How to use JSF generated HTML element ID with colon ":" in CSS selectors?
不知道你使用的語言綁定,但你應該能夠使用xpath來找到你需要的。下面是Python的一個例子:嘗試是這樣的:
driver.find_element_by_xpath("//@*[contains(., 'app.items(client.monthlyItems)')]")
您也可以嘗試starts-with
//*[@*[starts-with(., 'app.items')]]
更多細節here
我已經試過這一點,不能因爲atrribute有 「:」。我試圖找到正則表達式來找到它 – SUM
好吧,我已經更新了答案,以檢查包含的任何屬性。看看是否有效.. – Shaunak