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()
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)
@VladimirPodolyan Thank you. I have got the same issue with next environment:
Tried to experiment with โchrome driverโ options and when I disabled
options.add_experimental_option('w3c', False)methodfind_element(By.XPATH, "")again return {WebElement} instead of {dict} and methodclick()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 asoptionsarg. @lucielavickova-tesena May bee you need to delete this option for success passing in your driver versionno worries, glad we got it sorted!