kis_kis
kis_kis

Reputation: 11

How to extract multiline content from the <pre> tag in html using Selenium

Originally the element looks like this:

<pre>test_line1 test_line2 test_line3 test4</pre>

but when i double click it it looks like this:

<pre>test_line1
test_line2
test_line3
test4</pre>

linebreaks here are not recognized as \n or
what to do? i need to extract text and compare it with expected text and expected text can be written only in single line

String elementText = element.getText();
Assert.assertTrue(elementText,"test_line1 test_line2 test_line3 test4");
 Assert.assertTrue(elementText,"test_line1\ntest_line2\ntest_line3\ntest4");

Upvotes: 0

Views: 64

Answers (1)

Alex Karamfilov
Alex Karamfilov

Reputation: 674

You can try with something like this:

actualText.replaceAll("(\r\n|\n)", "");

This will remove all potential new line symbols from the text.

Upvotes: 0

Related Questions