pythonseleniumselenium-webdriverselenium4

python selenium 4.8.0 -


So i have a log-in script and i just try find element by class on newest version of selenium (4.8.0)

code:

button = browser.find_element(By.CLASS_NAME, 'just class name')

AND this code not working.

my stuff:

this is how the documentation searches for elements - By.CLASS_NAME, By.ID, etc...

https://www.selenium.dev/documentation/webdriver/elements/finders/

tried other variations of the code like find_element_by_ID and etc, installed an additional library for the selenium (I do not remember the name).


Solution

  • By.CLASS_NAME accepts only single classname as an argument. So you can't pass multiple classnames.


    Solution

    You can use either of the following locator strategies:

    As an alternative, you can also use a css_selector as follows:

    button = browser.find_element(By.CSS_SELECTOR, ".just.class.name")