Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cssSelector produces a different result to Chrome #1967

Open
samshutchins opened this issue Jun 8, 2023 · 0 comments
Open

cssSelector produces a different result to Chrome #1967

samshutchins opened this issue Jun 8, 2023 · 0 comments

Comments

@samshutchins
Copy link

    @Test
    void test()
    {
        final String html = """
            <html>
                <head>
                    <title>Funny ID</title>
                </head>
                <body>
                    <img src="/image.jpg" id="0% Platform Image" />
                </body>
            </html>""";

        final Document document = Jsoup.parse(html);
        final String jsoupSelector = document.getElementsByTag("img").get(0).cssSelector();
        final String chromeSelector = "#\\30 \\%\\ Platform\\ Image";
        
        assertEquals(chromeSelector, jsoupSelector);
    }

The CSS selector jsoup generates is #0\%\ Platform\ Image, and the one Chrome generates is #\30 \%\ Platform\ Image. The jsoup-generated one won't find the node in Chrome Dev Tools

I'm not too sure how CSS selectors should work, but I thought I'd point out the discrepency vs. Chrome.

@jhy jhy self-assigned this Jul 8, 2024
@jhy jhy added this to the 1.18.1 milestone Jul 8, 2024
@jhy jhy removed their assignment Jul 8, 2024
@jhy jhy removed this from the 1.18.1 milestone Jul 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants