具有替换< br>的WebDriver getText()方法.标签 [英] WebDriver getText() Method with Replace <br> Tag
本文介绍了具有替换< br>的WebDriver getText()方法.标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
HTML代码
<td class="left-align no-wrap-clmn">
<span style="color:orange">
In
<br>
Process
</span>
</td>
Webdriver使用getText方法获取In Process值
Webdriver to get the In Process value using getText method
代码:
String status = driver.findElement(By
.xpath("//*[@id='tblPortfolio']/tbody/tr[" + row
+ "]/td[13]")).getText();
上述代码以以下格式返回值
for the Above code Return the value with Following format
上述输出
In
Process
之后,我将使用IF语句传递上述值 代码:
after that i will pass the above value with IF Statement Code:
if (status.equals("In Process") {
}
问题:
由于新的行字符,它没有进入IF语句
因此,如何使用"In Process
"(使用我的getText())或IF语句中的任何更改进行输出
its not get into the IF Statment, because of the new Line char
so how can i make an output with "In Process
" (with my getText()) or any changes in IF Statement
推荐答案
您需要删除换行符,请尝试以下操作:
You need to remove the new line character, try this :
status.replaceAll("\\r\\n|\\r|\\n", " ");
它将删除所有带有空格的换行符.
It will remove all line breaks with space.
这篇关于具有替换< br>的WebDriver getText()方法.标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文