     [Answers](https://scrapfly.io/blog)   /  [playwright](https://scrapfly.io/blog/tag/playwright)   /  [How to find elements by CSS selectors in Playwright?](https://scrapfly.io/blog/answers/how-to-find-elements-by-css-selectors-in-playwright)   # How to find elements by CSS selectors in Playwright?

 by [Bernardas Alisauskas](https://scrapfly.io/blog/author/bernardas) Nov 03, 2022 1 min read [\#playwright](https://scrapfly.io/blog/tag/playwright) [\#python](https://scrapfly.io/blog/tag/python) 

 [  ](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fscrapfly.io%2Fblog%2Fanswers%2Fhow-to-find-elements-by-css-selectors-in-playwright "Share on LinkedIn")    

 

 

The most popular way to parse HTML content in web scraping are [CSS selectors](https://scrapfly.io/blog/posts/parsing-html-with-css) which are the default way to locate elements in Playwright as well. To find elements using CSS selectors we can use `page.locator()` method. For example:

python```python
from playwright.sync_api import sync_playwright

with sync_playwright() as pw:
    browser = pw.chromium.launch(headless=False)
    context = browser.new_context(viewport={"width": 1920, "height": 1080})
    page = context.new_page()
    page.goto("https://google.com/")

    h2_element = page.locator("h2.some-class")
```



⚠ It's possible that these commands will try to find elements *before* the page has fully loaded if it's a dynamic javascript page. For more see [How to wait for page to load in Playwright?](https://scrapfly.io/blog/answers/how-to-wait-for-page-to-load-in-playwright)

Also see: [How to find elements by XPath selectors in Playwright?](https://scrapfly.io/blog/answers/how-to-find-elements-by-xpath-in-playwright)



 

    



Scale Your Web Scraping

Anti-bot bypass, browser rendering, and rotating proxies, all in one API. Start with 1,000 free credits.

  No credit card required  1,000 free API credits  Anti-bot bypass included 

 [Start Free](https://scrapfly.io/register) [View Docs](https://scrapfly.io/docs/onboarding) 

 Not ready? Get our newsletter instead. 

 

## Explore this Article with AI

 [ ChatGPT ](https://chat.openai.com/?q=Summarize%20this%20page%3A%20https%3A%2F%2Fscrapfly.io%2Fblog%2Fanswers%2Fhow-to-find-elements-by-css-selectors-in-playwright) [ Gemini ](https://www.google.com/search?udm=50&aep=11&q=Summarize%20this%20page%3A%20https%3A%2F%2Fscrapfly.io%2Fblog%2Fanswers%2Fhow-to-find-elements-by-css-selectors-in-playwright) [ Grok ](https://x.com/i/grok?text=Summarize%20this%20page%3A%20https%3A%2F%2Fscrapfly.io%2Fblog%2Fanswers%2Fhow-to-find-elements-by-css-selectors-in-playwright) [ Perplexity ](https://www.perplexity.ai/search/new?q=Summarize%20this%20page%3A%20https%3A%2F%2Fscrapfly.io%2Fblog%2Fanswers%2Fhow-to-find-elements-by-css-selectors-in-playwright) [ Claude ](https://claude.ai/new?q=Summarize%20this%20page%3A%20https%3A%2F%2Fscrapfly.io%2Fblog%2Fanswers%2Fhow-to-find-elements-by-css-selectors-in-playwright) 



 ## Related Articles

 [  

 data-parsing css-selectors 

### Parsing HTML with CSS Selectors

Introduction to using CSS selectors to parse web-scraped content. Best practices, available tools and common challenges ...

 

 ](https://scrapfly.io/blog/posts/parsing-html-with-css) [  

 python ai 

### Find Web Elements with ChatGPT and XPath or CSS selectors

ChatGPT is becoming a popular assistant in web scraper development. In this article, we'll take a look at how to use it ...

 

 ](https://scrapfly.io/blog/posts/finding-web-selectors-with-chatgpt) [  

 python data-parsing 

### How to Parse Web Data with Python and Beautifulsoup

Beautifulsoup is one the most popular libraries in web scraping. In this tutorial, we'll take a hand-on overview of how ...

 

 ](https://scrapfly.io/blog/posts/web-scraping-with-python-beautifulsoup) 

  ## Related Questions

- [ Q How to find elements by XPath selectors in Playwright? ](https://scrapfly.io/blog/answers/how-to-find-elements-by-xpath-in-playwright)
- [ Q How to find elements by XPath in Puppeteer? ](https://scrapfly.io/blog/answers/how-to-find-elements-by-xpath-in-puppeteer)
- [ Q How to check if element exists in Playwright? ](https://scrapfly.io/blog/answers/how-to-check-for-element-in-playwright)
- [ Q How to find elements by XPath in Selenium ](https://scrapfly.io/blog/answers/how-to-find-elements-by-xpath-in-selenium)
 
  



   



 Run headless browsers at scale, **1,000 free credits** [Start Free](https://scrapfly.io/register)