[🐛 Bug]: FIND_ELEMENT command return a dict object value
See original GitHub issueWhat 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?
Issue Analytics
- State:
- Created 2 years ago
- Comments:15 (6 by maintainers)
Top Results From Across the Web
AttributeError: 'dict' object has no attribute 'click' error with ...
AttributeError: 'dict' object has no attribute 'click' error with find_element_by_css_selector() and click() using Selenium and ChromeDriver. ...
Read more >7. WebDriver API — Selenium Python Bindings 2 documentation
Returns : The command's JSON response loaded into a dictionary object. execute_async_script (script: str, *args) ...
Read more >Python Return Dictionary From Function - Finxter
To return a dictionary, first create the dict object within the function body, assign it to a variable your_dict , and return it...
Read more >Shadow DOM in Selenium - Titus on Testing
What's happening is that Selenium looks at return values from script execution commands and if it detects an element, it automatically converts ...
Read more >Python: Get Dictionary Key with the Max Value (4 Ways) • datagy
This isn't exactly what we'd expected. We were hoping to return 43 , or at least a number! Python dictionaries come built-in with...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@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 asoptions
arg. @lucielavickova-tesena May bee you need to delete this option for success passing in your driver version