I wonder if I could match an element by exact text via css-locators (The overall goal is to use it as a locator for Selenium
). I know the contains
method
For example:
<div><div>S - Subscriber</div></div>
I can retrieve it by css=div:contains('Subscriber')
or by css=div:contains('S - Subscriber')
but I need exact match. I tried css=div:contains('^S - Subscriber$')
and this element is not found.
One more point:
When we use xpath
we can assume that given text is in exact element by retrieving text with text()
function (for example //div[text()='S - Subscriber']
will point us exactly to the child div, whenever //div[contains(., 'S - Subscriber')]
will point us to the parent div, if i am not messed up), so is there equivalent in css another way then css=div > div:contains('S - Subscriber')
? I mean pointing just one element, without parent div.
Thanks in advance!