下面是我的html代码
<div class="form-row">
<div class="label-column"> Your Renewal Charges</div>
<div class="ctrl-column">
<span data-bind="html: DisplayYourRenewalCharges">
<span class="CurrencySymbol">USD</span>
95.00
</span>
我想取消续订金额(即 95.00 美元)
我的xpath:
String renewalCharge = driver
.findElement(
By.xpath("//div[contains(@data-bind,'html: DisplayYourRenewalCharges')]"))
.getText();
我的问题是另一个跨度类中可用的值,因此上面的 xpath 没有获取该值
所以请建议如何重新构建我的 xpath,以获得该值
最佳答案
试试这个。
driver.findElement(By.xpath("//span[@data-bind='html: DisplayYourRenewalCharges']")).getText()
关于java - 我们如何获得跨度值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23993829/