The beginning of the CSS Selector is wrong.

Searching for .freesim-text-last button span you will find two elements.

Pick the one which you're trying to reach using the follow:

.freesim-text-last button span:nth-of-type(1)

for the first element and

.freesim-text-last button span:nth-of-type(2)

for the second element.

Answer from João Farias on Stack Exchange
🌐
freeCodeCamp
forum.freecodecamp.org › python
Selenium | css-selector not found - Python - The freeCodeCamp Forum
April 1, 2021 - Hi, I’m trying stuf with selenium. For some reason the selector I get isn’t found. code: #Importing libraries from selenium import webdriver import pandas as pd from selenium.webdriver.common.keys import Keys import time # creating instance for web driver driver = webdriver.Chrome() driver.get("https://soundcloud.com/discover") print( driver.title) inputElement = driver.find_element_by_css_selector("#app > header > div > div.header__middle > div > form > input") inputElement.send_keys...
Discussions

python - Selenium can't find xpath or css selector - Stack Overflow
I'm trying to scrape this site that has pagination. The problem I'm facing is having selenium locate the next button. What I've tried: next_button = driver.find_element_by_css_selector( 'ul[cla... More on stackoverflow.com
🌐 stackoverflow.com
button - click() on css Selector not working in Selenium webdriver - Stack Overflow
HTML I don't have an id or name for this . Hence am writing FirefoxDriver driver = new FirefoxDriver(); d... More on stackoverflow.com
🌐 stackoverflow.com
java - CSS Locator with contains() InvalidSelectorException using Selenium WebDriver - Stack Overflow
Well that is the point I wanted to confirm. I was trying the locators from the IDE and the one I used was not working. BTW, I picked up the list from saucelabs.com/resources/selenium/css-selectors (Inner Text) and thought they were applicable for webdriver scripting as well. More on stackoverflow.com
🌐 stackoverflow.com
Css Selector button click with selenium (python) - Stack Overflow
Bring the best of human thought ... at your work. Explore Stack Internal ... I am trying to click on a button using selenium. My code states it is unable to find the css_selector with said class name. The class name has spaces in it, which lead me to use the css_selector object. When I try to pass the class name in the 'css_selector' object, it fails since the class name is a string, which is not ... More on stackoverflow.com
🌐 stackoverflow.com
🌐
Stack Overflow
stackoverflow.com › questions › 50175851 › selenium-webdriver-cssselector-not-working
java - Selenium + WebDriver cssSelector not working - Stack Overflow
May 4, 2018 - Possible duplicate of NoSuchElementExeption, selenium unable to locate element ... Is this in an IFRAME? Your locator looks fine for the HTML you've posted. If you could post a link to the site, we could more easily figure it out. ... WebDriverWait wait = new WebDriverWait(driver, 10); WebElement edit_button = wait.until(ExpectedConditions.elementToBeClickable(By.cssSelector("button#disablerun.btn.btn-primary"))); edit_button.click();
🌐
BrowserStack
browserstack.com › home › guide › mastering selenium css selectors in 2026
CSS Selector in Selenium: Locate Elements with Examples | BrowserStack
December 10, 2025 - I realized the issue wasn’t Selenium—it was that I wasn’t picking the right selectors for the right elements. Learning how CSS selectors actually work—and when to use each type—is what finally made my tests stable, readable, and far easier to maintain.
🌐
Software Testing Help
softwaretestinghelp.com › home › selenium automation › selenium – css selector for identifying web elements
Selenium - CSS Selector for Identifying Web Elements
May 9, 2025 - Locate/inspect the web element (“Email” textbox in our case) and notice that the HTML tag is “input” and the value of the ID attribute is “Email” and both of them collectively refer to the “Email Textbox”. Hence, the above data would create a CSS Selector. ... Type “css=input#Email” i.e. the locator value in the target box in the Selenium IDE and click on the Find button.
Find elsewhere
🌐
DevQA
devqa.io › selenium-css-selectors
Selenium CSS Selectors Examples
This tutorial provides examples of how to locate web elements in Selenium using CSS selectors. Let’s imagine we have a tag with the following attributes [id, class, name, value] <input type="text" id="fistname" name="first_name" class="myForm"> The generic way to locate elements by attribute is: css = element_name[<attribute_name>='<value>'] Example: WebElement firstName = driver.findElement(By.cssSelector("input[name='first_name']")); In CSS, we can use # notation to select the id attribute of an element: Example: driver.findElement(By.cssSelector("input#firstname")); //or driver.findElement(By.cssSelector("#firstname")); The same principle can be used to locate elements by their class attribute.
🌐
Reflect
reflect.run › articles › fixing-invalidselectorexception-in-selenium
How to fix an InvalidSelectorException in Selenium | Reflect
October 19, 2022 - The other common reason for hitting an InvalidSelectorException is that you’re using a feature of CSS or XPath that’s not supported by the underlying browser engine, and thus not supported by Selenium WebDriver. This is a more common problem with XPath selectors than CSS selectors. Since modern browsers only support the XPath 1.0 spec, which was released over twenty years ago, there are many XPath features that can be found online but which will never work in a web browser.
Top answer
1 of 2
2

As you've mentioned

The class name has spaces in it, which lead me to use the css_selector

this is right approach, however you should also make sure that one

  1. One should remove the space and put a .
  2. . represent class in CSS.

So the below code should work:

driver.find_element(By.CSS_SELECTOR, ".btn.btn-alt.see-full-list-btn")

or you can even use it with the tag a

driver.find_element(By.CSS_SELECTOR, "a.btn.btn-alt.see-full-list-btn")

or the recommended solution would be to use with explicit waits:

see_full_list_button = WebDriverWait(driver, 10).until(EC.visibility_of_element_located((By.CSS_SELECTOR, "a.btn.btn-alt.see-full-list-btn")))
see_full_list_button.click()

Imports:

from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
2 of 2
0

There is no necessity to focus on the element HTML after the click is already invoked.

As per the HTML

<a href="#" class="btn btn-alt see-full-list-btn">See Full List</a>

you can use either of the following locator strategies:

  • Using link_text:

    driver.find_element(By.LINK_TEXT, "See Full List").click()
    
  • Using css_selector:

    driver.find_element(By.CSS_SELECTOR, "a.btn.btn-alt.see-full-list-btn").click()
    
  • Using xpath:

    driver.find_element(By.XPATH, "//a[@class='btn btn-alt see-full-list-btn' and text()='See Full List']").click()
    

Ideally to click on the clickable element you need to induce WebDriverWait for the element_to_be_clickable() and you can use either of the following locator strategies:

  • Using LINK_TEXT:

    WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.LINK_TEXT, "See Full List"))).click()
    
  • Using CSS_SELECTOR:

    WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.CSS_SELECTOR, "a.btn.btn-alt.see-full-list-btn"))).click()
    
  • Using XPATH:

    WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "//a[@class='btn btn-alt see-full-list-btn' and text()='See Full List']"))).click()
    
  • Note: You have to add the following imports :

    from selenium.webdriver.support.ui import WebDriverWait
    from selenium.webdriver.common.by import By
    from selenium.webdriver.support import expected_conditions as EC
    
🌐
Sauce Labs
saucelabs.com › home › blog › selenium tips: css selectors
Selenium Tips: CSS Selectors
April 2, 2023 - CSS in Selenium has an interesting feature of allowing partial string matches using ^=, $=, or *=. I’ll define them, then show an example of each: ... An earlier version of this article references :contains, a powerful way to match elements that had a desired inner text block. Sadly, that feature is deprecated and not supported any longer by the W3C Standard. The current · CSS Selectors level 3 standard is implemented by all major browsers; level 4 is in working draft mode.
🌐
Reddit
reddit.com › r/learnpython › unable to use css selector in selenium
r/learnpython on Reddit: Unable to use CSS Selector in Selenium
July 14, 2020 -

I'm following the Automate The Boring Stuff course on Udemy by u/AlSwiegart. I'm on section 13 Web Scraping - 41. Controlling the Browser with the Selenium Module. I think possibly that some of the Selenium module's input syntax/requirements have changed since the video tutorial was made.

I've downloaded the chromedriver and geckodriver and added them to PATH in Windows 10. The following works to open both browsers.

driver.get('insert URL here')

I'm trying to assign a CSS Selector to a variable. The code in the video is

elem = driver.find_element_by_css_selector('insert copied css selector path here')

This gives the following error:

Traceback (most recent call last):
  File "<pyshell#13>", line 1, in <module>
    elem = driver.find_element_by_css_selector('.main > div:nth-child(1) > div:nth-child(3) > center:nth-child(1) > a:nth-child(1) > img:nth-child(1)')
  File "C:\Users\Gaz\AppData\Local\Programs\Python\Python38-32\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 598, in find_element_by_css_selector
    return self.find_element(by=By.CSS_SELECTOR, value=css_selector)
  File "C:\Users\Gaz\AppData\Local\Programs\Python\Python38-32\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 976, in find_element
    return self.execute(Command.FIND_ELEMENT, {
  File "C:\Users\Gaz\AppData\Local\Programs\Python\Python38-32\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 321, in execute
    self.error_handler.check_response(response)
  File "C:\Users\Gaz\AppData\Local\Programs\Python\Python38-32\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 242, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: Failed to decode response from marionette

I looked on the Selenium.dev website and the code there differs slightly. So I tried:

elem = driver.find_element(By.CSS_SELECTOR, "Insert copied CSS Selector Path Here")

This gives the following error:

Traceback (most recent call last):
  File "<pyshell#19>", line 1, in <module>
    elem = driver.find_element(By.CSS_SELECTOR, ".main > div:nth-child(1) > div:nth-child(3) > center:nth-child(1) > a:nth-child(1) > img:nth-child(1)")
NameError: name 'By' is not defined

Any help is appreciated.

🌐
Stack Overflow
stackoverflow.com › questions › 69667935 › selenium-4-find-element-by-css-selector-not-working
Selenium 4. find_element_by_css_selector not working - Stack Overflow
Bring the best of human thought and AI automation together at your work. Explore Stack Internal ... Based on the Selenium documentation the find element by css selector syntax is element = driver.find_element_by_css_selector('#foo') but the example shows there is a.nav before the # sign ‘(a.nav#home)’ which based on this website is HTML tag.