This selector should work but will be more efficient if you replace it with your suited markup:
//*[contains(@class, 'Test')]
Or, since we know the sought element is a div
:
//div[contains(@class, 'Test')]
But since this will also match cases like class="Testvalue"
or class="newTest"
, @Tomalak's version provided in the comments is better:
//div[contains(concat(' ', @class, ' '), ' Test ')]
If you wished to be really certain that it will match correctly, you could also use the normalize-space function to clean up stray whitespace characters around the class name (as mentioned by @Terry):
//div[contains(concat(' ', normalize-space(@class), ' '), ' Test ')]
Note that in all these versions, the * should best be replaced by whatever element name you actually wish to match, unless you wish to search each and every element in the document for the given condition.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…