- 
          
 - 
                Notifications
    
You must be signed in to change notification settings  - Fork 8.6k
 
Description
What happened?
Issue
While executing tests on a remote driver (BrowserStack), when the method find_element() doesn't find the element instead of throwing the NoSuchElementException it is returning the dict with the error.
This causes issues, for example, on the ExpectedConditions library which isn't expecting a dict as the response and generates a AttributeError: 'dict' object has no attribute 'is_displayed'
Possible cause
I've been doing some investigation and I think the issue is that the response sent to the remote/ErrorHandler.check_response() method doesn't contain a "status" field, e.g.:
response = {'value': {'error': 'no such element', 'message': 'no such element: Unable to locate element: {"method":"xpath","selector":"//span[contains(text(), 'SET DISPOSITION')]/.. | //button[contains(text(), 'Set Disposition')]"}\n (Session info: chrome=128.0.6613.85)', 'stacktrace': '\tGetHandleVerifier [0x00007FF61A05B632 29090]\n\t(No symbol) [0x00007FF619FCE6E9]\n\t(No symbol) [0x00007FF619E8B1CA]\n\t(No...No symbol) [0x00007FF619FC4A7F]\n\tBaseThreadInitThunk [0x00007FFC08C3257D 29]\n\tRtlUserThreadStart [0x00007FFC0990AA78 40]\n'}}
As far as I can tell, the issue is only happening on the remote webdriver after setting an implicitly_wait > 1.
How can we reproduce the issue?
Example code:
    options = webdriver.ChromeOptions()
    driver = webdriver.Remote(command_executor=server, options=options)
    driver.implicitly_wait(30)
    driver.find_element(By.XPATH, value="Non-Existing Element")Relevant log output
>               modal = self.driver.find_element(By.XPATH, "Modal_XPATH")
>               if modal.is_displayed():
E               AttributeError: 'dict' object has no attribute 'is_displayed'
../../SOMETHING/SOMETHING.py:174: AttributeErrorOperating System
Windows 11
Selenium version
Python 4.19.0
What are the browser(s) and version(s) where you see this issue?
Chrome 128
What are the browser driver(s) and version(s) where you see this issue?
ChromeDriver 128.0.6613.137
Are you using Selenium Grid?
No