user3446229
user3446229

Reputation: 95

How to verify that the text is written in two lines Selenium

In my test i must verify that the text of the Button is written in two lines: Example: Line 1 Line 2

<div class="ClassName">
Line 1
<br/>
<br/>
Line 2
</div>

The only Solution that I find is to verify that this balise contain the two texts et it work but that didn't verify that the text is written in two lines.

The xpath that I use is the folowing:

.//div[text()[contains(.,"Line 2")] and text()[contains(.,"Line 2")]]

Thanks!

Upvotes: 0

Views: 950

Answers (1)

Marcel
Marcel

Reputation: 1463

Using your example, you could use the following xpath to only get the div if the div contains the text 'Line 1' and 'Line 2' and more than one br tag

//div[contains(., 'Line 1') and contains(., 'Line 2') and count(br) > 1]

Upvotes: 1

Related Questions