我有
`<button class="button button--chromeless" data-action="select-anchor" data-action-value="fba4">Top highlight</button>`
我需要从data-action-value获得结果“fba4”。
我试过了:
IWebElement ell = driver.FindElement(By.CssSelector("button[data-action-value]"));
我认为我需要基于Top亮点才能获得价值fba4,但我不知道如何?
答案 0 :(得分:3)
使用 SELECT c.*,
(SELECT count(b.id) FROM branches b WHERE b.city_id=c.id) AS No_of_Branch,
(SELECT count(e.id) FROM employees e WHERE e.city_id=c.id) AS no_of_employee
FROM city c
.GetAttribute("data-action-value")
您也可以在Xpath下面使用
string element = driver.FindElement(By.CssSelector("button[data-action-value]")).GetAttribute("data-action-value");
您可以使用
//button[@class='button button--chromeless']/@data-action-value
希望它会对你有所帮助:)。
答案 1 :(得分:1)
要从上面的HTML获取'fba4',请尝试
string ell = driver.FindElement(By.CssSelector("button[class='button button--chromeless']")).GetAttribute("data-action-value");