What tool can I use to test the :contains() CSS3 pseudo-class in a browser?

后端 未结 2 1810
旧巷少年郎
旧巷少年郎 2021-01-19 13:40

I am trying to develop CSS selectors to use with Selenium. In particular I want to use the pseudo-class :contains(). Although the W3 has a draft of CSS3 with :contains() i

相关标签:
2条回答
  • 2021-01-19 14:19

    jQuery's selector engine also implements the :contains() pseudo-class. It is to my knowledge that jQuery and Selenium implement it the same way.

    I'm not sure how you would be able to test it on sites that don't make use of jQuery, but on sites that do, it's just a matter of firing up your browser's JavaScript console, and running jQuery selectors in the console.

    Here's an example with viewing this very Stack Overflow question on Chrome's JavaScript console (you may get different results depending on whether you're logged in or not):

    > $("#mainbar div[id]:contains('selector')").get() /* DOM objects with .get() */
    
    [<div class=​"question" id=​"question">​…​</div>​, <div id=​"answers">​…​</div>​, <div id=​"answer-9007154" class=​"answer">​…​</div>, <div id=​"answer-9008184" class=​"answer">​…​</div>​]
    
    0 讨论(0)
  • 2021-01-19 14:28

    I'm not seeing the :contains() selector anywhere and have never encountered it myself.

    No pseudo-class comes up: http://caniuse.com/#search=contain

    0 讨论(0)
提交回复
热议问题