I am having a problem selecting nodes by attribute when the attributes contains more than one word. For example:
You can try the following
By.CssSelector("div.atag.btag")
mjv's answer is a good start but will fail if atag is not the first classname listed.
The usual approach is the rather unwieldy:
//*[contains(concat(' ', @class, ' '), ' atag ')]
this works as long as classes are separated by spaces only, and not other forms of whitespace. This is almost always the case. If it might not be, you have to make it more unwieldy still:
//*[contains(concat(' ', normalize-space(@class), ' '), ' atag ')]
(Selecting by classname-like space-separated strings is such a common case it's surprising there isn't a specific XPath function for it, like CSS3's '[class~="atag"]'.)
I came here searching solution for Ranorex Studio 9.0.1. There is no contains() there yet. Instead we can use regex like:
div[@class~'atag']
try this: //*[contains(@class, 'atag')]