assetEquals 不希望返回,但 .getText 返回新行。我怎样才能使 .getText() 不返回新行?我累了:
assertEquals("first last\n address 1\n state zip\n Country\n email@email.com\n +353 3456546", driver.findElement(By.xpath("//form[@id='mainForm']/div[2]/div")).replaceAll("\n", ""));
但这似乎不起作用。
try {
assertEquals("first last\n address 1\n state zip\n Country\n email@email.com\n +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
有人对如何解决此问题有任何建议吗?