hurracom / WebConsoleTap

Simple extension based on JSErrorCollector used to tap into JavaScript errors and warnings and allow fetching them later, e.g. via WebDriver JS Interface.
GNU General Public License v3.0
7 stars 0 forks source link

JavascriptException: Message: TypeError: window.console.requestDump is not a function #3

Open rsingh-03 opened 5 years ago

rsingh-03 commented 5 years ago

Getting above error while capturing logs using webconssoleTap

LeHack commented 5 years ago

Hello, have you verified that the extension loads correctly (is visible and enabled in the Addons/Extensions?)

rsingh-03 commented 5 years ago

yes,extension is loaded correctly in Extensions. but still getting

Traceback (most recent call last): File "browserlogs.py", line 133, in consoleLog = driver.execute_script("window.console.requestDump()") File "C:\Python27\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 636, in execute_script 'args': converted_args})['value'] File "C:\Python27\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 321, in execute self.error_handler.check_response(response) File "C:\Python27\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 242, in check_response raise exception_class(message, screen, stacktrace) selenium.common.exceptions.JavascriptException: Message: TypeError: window.console.requestDump is not a function

It worked 2 times, I was able to get logs but then it started failing with above mentioned error

p=extension_dir + 'webconsoletap-1.0-fx.xpi' print p f = webdriver.FirefoxProfile() f.add_extension('C:\Users\gs\Desktop\webconsoletap-1.0-fx.xpi') f.set_preference('media.navigator.permission.disabled', True)

f.update_preferences() driver = webdriver.Firefox(firefox_profile=f)

rsingh-03 commented 5 years ago

Also I tried to use already present profile with webconsoletap installed in it ,It shows in addsON when I launch FF but get the same error as above.

f = webdriver.FirefoxProfile('C:\Users\gs-0815\AppData\Roaming\Mozilla\Firefox\Profiles\dmb0yt8y.Test')

''' op = Options() op.add_argument("--load-extension=" + p)'''

d = DesiredCapabilities.FIREFOX d['firefox_profile']=f.encoded driver = webdriver.Firefox(desired_capabilities=d)

LeHack commented 5 years ago

Well the only way I managed to get this error was to navigate to a special address like about:config or file:///path/to/file

Please note that the manifest file for this extension has a match set to: ":///*" which according to MDN docs should match all standard web pages, excluding resources like file/ftp etc. Possibly I could change it to , but that still won't match resource://a/b/c (like file://).

The other scenario that comes to my mind is that at the time of calling requestDump(), the page is loading (e.g. you click save on some form and don't wait for the action to finish). This would explain a lot, since the addon only loads when the page has finished loading. Could you please add some wait to make sure that's not the case? e.g. for java:

WebDriverWait wait = new WebDriverWait(driver, 30); // wait at most 30s
wait.until((ExpectedCondition<Boolean>) wd ->
    ((JavascriptExecutor) wd).executeScript("return document.readyState").equals("complete"));
rsingh-03 commented 5 years ago

or else you can give it a try to load for http://web.fuze.com and try to load extension to repro this issue

rsingh-03 commented 5 years ago

I have tried to wait for almost 60 secs after driver.get().still same error

LeHack commented 5 years ago

Ok, I'll have a go at it. I can see you're using the python API on windows. What firefox version?

rsingh-03 commented 5 years ago

firefox version 65 .Please do update in case of any luck ..This is really urgent issue for me

LeHack commented 5 years ago

Ok, I finally found a moment to check this out and it turns out that Fuze itself overwrites the window.console with it's own implementation, so:

Thus with the current implementation this addon will never work for such an app. Possibly there is another way to collect the logs, but I would need to do some more research on that and unfortunately I don't currently have time to do that. Do stay tuned in however, maybe I'll come up with something later (but do note that it'll be more as in weeks, not days).

If you're in contact with the sites developers, ask them whether maybe there's a debug flag which you could toggle when running the tests in order to disable the window.console override in the sites code.

I'm afraid there is nothing more I can do to help you with your task.

abulhol commented 5 years ago

Using Selenium 3.13.0, I can only get this to work if I use driver.install_addon("/tmp/webconsoletap-1.0-fx.xpi", temporary=True) i.e. using add_extension on the profile does not work. In the latter case, the extension and its methods, e.g. requestDump are not available.