assetEquals不需要返回,但是.getText返回新行。如何使.getText()不返回新行?我累了:
assertEquals("first lastn address 1n state zipn Countryn email@email.comn +353 3456546", driver.findElement(By.xpath("//form[@id='mainForm']/div[2]/div")).replaceAll("n", ""));
但这似乎并不奏效。
try {
assertEquals("first lastn address 1n state zipn Countryn email@email.comn +353 3456546", driver.findElement(By.xpath("//form[@id='mainForm']/div[2]/div")).getText());
//
} catch (Error e) {
verificationErrors.append(e.toString());
//e.printStackTrace();
}
java.lang.AssertionError: java.lang.AssertionError: Expected "first last address 1 state zip country email@email.com +353 3456546" but saw "first last
address 1
state zip
country
email@email.com
+353 3456546" instead
有人对如何解决这个问题有什么建议吗?
replace("n", "");
怎么样?replaceAll
采用regex,而n
是String
文字,而不是regex。