Unable to locate element: .stimulus
TGWaffles opened this issue · 3 comments
Running the usage example script in a regular python console returns the following traceback:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<stdin>", line 3, in chat
File "/usr/local/lib/python3.8/dist-packages/cleverbotfree/cbfree.py", line 129, in single_exchange
self.get_form()
File "/usr/local/lib/python3.8/dist-packages/cleverbotfree/cbfree.py", line 57, in get_form
self.elem = self.browser.find_element_by_class_name('stimulus')
File "/usr/local/lib/python3.8/dist-packages/selenium/webdriver/remote/webdriver.py", line 564, in find_element_by_class_name
return self.find_element(by=By.CLASS_NAME, value=name)
File "/usr/local/lib/python3.8/dist-packages/selenium/webdriver/remote/webdriver.py", line 976, in find_element
return self.execute(Command.FIND_ELEMENT, {
File "/usr/local/lib/python3.8/dist-packages/selenium/webdriver/remote/webdriver.py", line 321, in execute
self.error_handler.check_response(response)
File "/usr/local/lib/python3.8/dist-packages/selenium/webdriver/remote/errorhandler.py", line 242, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.NoSuchElementException: Message: Unable to locate element: .stimulus
It appears they made some changes to the website, breaking this. Working on a fix now.
I think they might be detecting the use of selenium/webdriver now, and preventing stuff that needs to load on the page for us to communicate with the bot.
I've tried swapping geckodriver for chromedriver, using random User-Agents, time delaying clicks, etc. Can't seem to get anything to work. I may be forced to re-write this with pypupeteer instead of selenium.
Working on a re-write using python-playwright. Tests seem to be working, will have a new version of this working soon.
I re_wrote the module to use playwright instead of selenium. I think everything should be working now, I did some minimal testing. This introduces some breaking changes to the modules use, but it's the best I can do. Please let me know if you find any issues with the new code in a new issue, as I'll be closing this out now.