As part of my test, the system is supposed to find out if the device being used to open the website is a mobile device or a normal desktop.
I keep getting the error:
You seem to be missing the closing round and square brackets:
Change this:
//body[contains(@class, 'is-mobile'
Into this:
//body[contains(@class, 'is-mobile')]
As a side note, take into account that this code has another slightly hidden issue and it is that you will match things that you do not want to match such as this class attribute: login-page not-is-mobile
.
There is no way to simply match that as you would using the CSS3 selector [class~="is-mobile"]
. However, you can come around this by doing this:
//body[contains(concat(' ', @class, ' '), ' is-mobile ')]
All those spaces are there to make sure you will match only something between spaces and that it also matches even if it is at the beginning or end of the class attribute.
It is ugly indeed but that is the XPath way of doing this.