【发布时间】:2015-02-13 08:20:41
【问题描述】:
在这段 HTML 代码中,我需要使用 selenium testng 获取“Status”文本。
<div class="dojoxGridSortNode">Status</div>
我将代码用作
public static String gettext(){
String Value = null;
try{
Value = webElement.getAttribute("text");
APP_LOGS.debug("Get Text on"+locatorDescription);
}
使用此代码,我无法从 html 代码中获取文本。他们还有其他选项可以从 html 属性中获取文本吗?我也使用了 .getText() 方法。
提前致谢
【问题讨论】:
-
jsoup中如何使用?
-
getText() 方法必须有效。如果您没有传递正确的 webelement,那么它不会传递。请尝试使用正确的 Webelement 以获取文本。
-
你的
webElement到底是什么?请务必阅读上述链接问题中的答案。