Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Illegal CSS Selector

I want to use this CSS selector with Selenium webdriver

#coordinatonTable .odd:not(:has(.dataTables_empty))

I get an "An invalid or illegal string was specified" error. I tried the jquery selector test from w3schools. Also this service show me "illegal selector". If I shorten the selector it works

#short .odd:not(:has(.dataTables_empty))
#coordinatonTable .odd:not(:has(.short))
#short .odd:not(:has(.short))

Looks like the selector is to long. But this can not really be true. Any suggest?

The structure of the html part is like this:

id="coordinatonTable"
  class="odd"
    class="dataTables_empty"
  class="odd"
    class="something"
  class="odd"
    class="somethingelse"
  ...

I want get all odd element if they has no empty child.

like image 434
user1482309 Avatar asked Nov 17 '25 10:11

user1482309


2 Answers

:has is not a valid CSS selector. It is a jQuery extension and will be invalid in any CSS file.

I have no idea why your other examples didn't cause an error. They do for me.

like image 93
lonesomeday Avatar answered Nov 19 '25 01:11

lonesomeday


:has is a jQuery selector - it's not part of the CSS3 spec. If you're just checking for the non-presence of a class, do:

#coordinatonTable .odd:not(.dataTables_empty)

like image 21
alexpls Avatar answered Nov 19 '25 02:11

alexpls



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!