How can I find an element by CSS class with XPath?

前端 未结 6 1264
刺人心
刺人心 2020-11-22 08:43

In my webpage, there\'s a div with a class named Test.

How can I find it with XPath?

6条回答
  •  盖世英雄少女心
    2020-11-22 09:12

    XPath has a contains-token function, specifically designed for this situation:

    //div[contains-token(@class, 'Test')]
    

    It's only supported in the latest version of XPath (3.1) so you'll need an up-to-date implementation.

提交回复
热议问题