Debugging Selenium script with EventFiringWebDriver in PyCharm, cause exception to be logged:
'WebDriver' object has no attribute '__len__'
It slows down IDE but do not break (stop) the script.
Here is full code:
from selenium import webdriver
from selenium.webdriver.support.event_firing_webdriver import EventFiringWebDriver
from selenium.webdriver.support.events import AbstractEventListener
class ScreenshotListener(AbstractEventListener):
def on_exception(self, exception, driver):
print(exception)
driver = webdriver.Chrome('chromedriver.exe')
ef_driver = EventFiringWebDriver(driver, ScreenshotListener())
ef_driver.get('https://google.com/')
title = ef_driver.title
driver.quit()
assert "Google", title
When I run attached script in standard mode everything is OK.
But running with PyCharm Debug (here is output from beginning of Debug console):
C:\Pro\selenium-debug\venv\Scripts\python.exe "C:\Program Files\JetBrains\PyCharm Community Edition 2020.1.1\plugins\python-ce\helpers\pydev\pydevd.py" --multiproc --qt-support=auto --client 127.0.0.1 --port 59668 --file C:/Pro/selenium-debug/simple_test.py
I get those exceptions (every time when I call ef_driver):
'WebDriver' object has no attribute '__len__'
'WebDriver' object has no attribute '__len__'
It not stopping the script, it just cause debugger to be slow (it updates driver and focus is set to the browser).
Any idea why it is triggered and logged?
Bonus: Running debugging in console with pdb is OK, so this looks like strictly PyCharm Debug connected thing