如何使用Selenium和Java提取文本?

问题描述 投票:0回答:1

[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

我不确定我在这里犯了什么错误。

java selenium xpath gettext getattribute
1个回答
0
投票

要提取文本应用的配置:测试,MSA测试,MSACONFIGURABLE

© www.soinside.com 2019 - 2024. All rights reserved.