[getText()
,getAttribute("textContent")
未返回正确的结果。
这是带有标签的html标签:
<span>
class="panel-title text-primary header-font ng-binding" ng-click="titleLink()" style="" xpath="1">Applied Configs: TEST, MSA TEST, MSACONFIGURABLE
</span>
代码试用:
driver.findElement(By.xpath("//*[contains(@name,'Applied Configs')]/div[1]")).getAttribute("textContent"));
或
driver.findElement(By.xpath("//*[contains(@name,'Applied Configs')]/div[1]")).getText();
返回Applied Configs:
,而不是完整的文本Applied Configs: TEST, MSA TEST, MSACONFIGURABLE
。
我不确定我在这里犯了什么错误。
要提取文本应用的配置:测试,MSA测试,MSACONFIGURABLE