3

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.

Alfira
  • 93
  • 1
  • 9

1 Answers1

5

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']
LarsH
  • 27,481
  • 8
  • 94
  • 152
JLRishe
  • 99,490
  • 19
  • 131
  • 169
  • Thanks @jlrishe, it helped. But example is little bit incorrect. I have changed it to : `//*[normalize-space(@text)='Test string with new line']` and now it works. – Alfira Feb 09 '15 at 08:43