selenium: [๐Ÿ› Bug]: FIND_ELEMENT command return a dict object value

What happened?

I was updated my selenium version to 4.0.0 from 3.141.0. After that webdriver.find_element() returns dict value, but WebElement is expected in that case. Bug reproduced with attached code in 4.0.0 and not relevant for 3.141.0 version.

In images you can review the difference in that versions for return of webdriver.find_element()

SM1 SM

How can we reproduce the issue?

from selenium.webdriver.chrome.webdriver import WebDriver
from selenium.webdriver.common.by import By

if __name__ == '__main__':
    driver = WebDriver()
    driver.get('https://www.selenium.dev/')
    element = driver.find_element(by=By.CSS_SELECTOR, value='input[type=search]')
    element.click()

Relevant log output

Traceback (most recent call last):
  File "PycharmProjects/selenium_bug/main.py", line 8, in <module>
    element.click()
AttributeError: 'dict' object has no attribute 'click'

Operating System

MacOS Big Sur

Selenium version

4.0.0

What are the browser(s) and version(s) where you see this issue?

Chrome 94.0.4606.81

What are the browser driver(s) and version(s) where you see this issue?

ChromeDriver 94.0.4606.61

Are you using Selenium Grid?

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 15 (6 by maintainers)

Most upvoted comments

@VladimirPodolyan Thank you. I have got the same issue with next environment:

  • ChromeDriver 95.0.4638.17
  • Selenium 4.0.0

Tried to experiment with โ€œchrome driverโ€ options and when I disabled options.add_experimental_option('w3c', False) method find_element(By.XPATH, "") again return {WebElement} instead of {dict} and method click()works as usual.

I was figured it out. Itโ€™s caused due to using and passing chrome_options.add_experimental_option('w3c', False) into driver instance as options arg. @lucielavickova-tesena May bee you need to delete this option for success passing in your driver version

no worries, glad we got it sorted!