When getting a page with selenium from a python script, using htmlunit through a remote webdriver, I get this error:
WebDriverException: Message: u'TypeError: Cannot find function addEventListener in object [object HTMLDocument]. (https://xxx.xxx.com/static/js/jquery-2.0.3.min.js#4)
So to avoid this exception I tried to disable javascript when initializing my webdriver, but I can't manage to do it...
I tried to set the desired_capabilities with webdriver.DesiredCapabilities.HTMLUNIT (vs HTMLUNITWITHJS), but nothing changed. So I tried to define the capabilities manually, but it didn't help.
Here are some examples of what I did, with the results:
In [45]: driver = webdriver.Remote(desired_capabilities=webdriver.DesiredCapabilities.HTMLUNIT)
In [46]: driver.desired_capabilities
Out[46]:
{u'browserName': u'htmlunit',
u'cssSelectorsEnabled': True,
u'javascriptEnabled': True,
u'platform': u'LINUX',
u'version': None,
u'webdriver.remote.sessionid': u'3aa1c9c0-9d85-4e22-ad2b-1116950cf86d'}
In [47]: driver = webdriver.Remote(desired_capabilities={'browserName': 'htmlunit', 'javascriptEnabled': False, 'platform': 'ANY', 'version': ''})
In [48]: driver.desired_capabilities
Out[48]:
{u'browserName': u'htmlunit',
u'cssSelectorsEnabled': True,
u'javascriptEnabled': True,
u'platform': u'LINUX',
u'version': None,
u'webdriver.remote.sessionid': u'426aef71-2b7c-45c5-9313-c3dbbec07c7f'}
So here I am. If someone has any idea... :)