The tag structure is shown in the screenshot.

I am trying to use this python code to access the first element li:
invitations = elem.find_element_by_css_selector('members-holder li#invitation-holder > :first-child')
elem is a top-level element containing all tags
I got this exception:
NoSuchElementException: Message: Unable to locate element: {"method":"css selector","selector":"members-holder li#invitation-holder > :first-child"}
I tried several options, but cannot get the result that I want. What is the best way to select the specified item?
EDIT
I tried an alternate css selector .members-holder .invitation-holder:first-childin the developer console in Chrome and it works. But when I plug it in selenium python code, the same exception is thrown.
source
share