Reputation: 113
In the Mobile application view I see text like this:
Test string
with new line
But in the elements tree of this view (it looks like expandible tree viewer) I see value of the @text attribute of this one like this:
Test stringwith new line
I have tried to use the following ways:
xpath=//*[@text='Test string\nwith new line']
xpath=//*[@text=concat('Test string','\n','with new line']
But they don't work.
Is it possible to select element by its @text attribute containing new line? If it is possible How to do that?
Note: I don't have ability to see source code and change it.
Upvotes: 3
Views: 6544
Reputation: 101680
I don't know of a good way to place a single newline character into an XPath, but you could use normalize-space()
if your main objective is to select the element and the fact that it contains a newline isn't all that important:
//*[normalize-space(@text) = 'Test string with new line']
Upvotes: 5