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

 by [Bernardas Alisauskas](https://scrapfly.io/blog/author/bernardas) Oct 26, 2022 1 min read [\#css-selectors](https://scrapfly.io/blog/tag/css-selectors) [\#data-parsing](https://scrapfly.io/blog/tag/data-parsing) [\#selenium](https://scrapfly.io/blog/tag/selenium) 

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

 

 

[CSS selectors](https://scrapfly.io/blog/posts/parsing-html-with-css) are one of the most popular ways to parse HTML pages when web scraping. Using Selenium, to find elements by CSS selectors we can use `driver.find_element()` and `driver.find_elements()` methods:

python```python
from selenium import webdriver
from selenium.webdriver.common.by import By

driver = webdriver.Chrome()
driver.get("https://httpbin.dev/html")

element = driver.find_element(By.CSS_SELECTOR, 'p')
# then we can get the element text
print(element.text)
"Availing himself of the mild, summer-cool weather that now reigned in these latitudes..."
# we can also get tag name and attributes:
print(element.tag_name)
print(element.get_attribute("class"))

# for multiple elements we need to iterate
for element in driver.find_elements(By.CSS_SELECTOR, 'p'):
    print(element.text)

driver.close()
```



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



 

    



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-selenium) [ 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-selenium) [ 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-selenium) [ 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-selenium) [ 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-selenium) 



 ## 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) [     

 data-parsing css-selectors 

### Ultimate CSS Selector Cheatsheet for Web Scraping and HTML Parsing

CSS selectors is a powerful HTML querying protocol which is used by browsers to determine what HTML elements to style. I...

 

 ](https://scrapfly.io/blog/posts/css-selector-cheatsheet) [  

 python headless-browser 

### Web Scraping with Selenium and Python

Introduction to web scraping dynamic javascript powered websites and web apps using Selenium browser automation library ...

 

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

  ## Related Questions

- [ Q How to find elements by XPath in Selenium ](https://scrapfly.io/blog/answers/how-to-find-elements-by-xpath-in-selenium)
- [ Q How to find HTML elements by class? ](https://scrapfly.io/blog/answers/how-to-find-html-elements-by-class)
- [ Q How to select HTML elements by text using CSS Selectors? ](https://scrapfly.io/blog/answers/how-to-select-elements-by-text-using-css-selectors)
- [ Q How to select elements by ID using CSS selectors? ](https://scrapfly.io/blog/answers/how-to-select-elements-by-id-css-selectors)
 
  



   



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