2022-02-26

How to find_elements with multiple attributes using cssSelector Python and Selenium

I'm trying to find all the elements that have <a href=....> inside the <div id="contents" ...>

Here is the HTML code:

<div id="contents" class="style-scope">
    <div id="dismissible" class="style-scope">
        <a id="thumbnail" href="http://www.test.com">

Here is my python code:

items = driver.find_elements(By.cssSelector("div[id="contents"] a[id="thumbnail"]"))

It gives me the error:

SyntaxError: invalid syntax. Perhaps you forgot a comma?

Where do I need to put the comma?



No comments:

Post a Comment