Both Chrome
and PhantomJS
selenium drivers can log everything that is going on the browser side. By specifying the service log path while initializing the driver, you can control where the logs would be written to. E.g. for chrome (in Python):
from selenium import webdriver
driver = webdriver.Chrome(service_log_path="/tmp/log")
driver.get("http://www.google.com")
driver.close()
After executing the code, /tmp/log
file would contain the service logs which is helpful for debugging:
[0.985][INFO]: Launching chrome: ...
[2.620][INFO]: RESPONSE InitSession {
"acceptSslCerts": true,
"applicationCacheEnabled": false,
"browserConnectionEnabled": false,
"browserName": "chrome",
"chrome": {
"userDataDir": "/var/folders/yy/ppdg927x4zv8b0rbzg1f_jzh0000gn/T/.org.chromium.Chromium.ibsof9"
},
"cssSelectorsEnabled": true,
"databaseEnabled": false,
"handlesAlerts": true,
"javascriptEnabled": true,
"locationContextEnabled": true,
"nativeEvents": true,
"platform": "Mac OS X",
"rotatable": false,
"takesHeapSnapshot": true,
"takesScreenshot": true,
"version": "37.0.2062.120",
"webStorageEnabled": true
}
[2.677][INFO]: Waiting for pending navigations...
[2.696][INFO]: Done waiting for pending navigations
[3.290][INFO]: Waiting for pending navigations...
[4.338][INFO]: Done waiting for pending navigations
[4.338][INFO]: RESPONSE Navigate
[4.339][INFO]: COMMAND CloseWindow {
}
[4.451][INFO]: RESPONSE CloseWindow
Is there a way to get the same information but using Firefox
web driver?
From what I see in the source code, both Chrome
and PhantomJS
fire up new services via subprocess
and pass the --log-path
argument to it. And these services are responsible for the logging. As for Firefox
driver, it's implementation is quite different and is based on FirefoxBinary
class.
Provided example and links are Python-related, but the question is pretty much generic and language-agnostic. Would appreciate any pointers.
geckodriver provides different bands of logs for different audiences. The most important log entries are shown to everyone by default, and these include which port geckodriver provides the WebDriver API on, as well as informative warnings, errors, and fatal exceptions.
Hi, Logs, there are no logs. If you are looking for history you can find that in several places like mouse to the top of the browser to a empty spot and Right Click and turn on the Menu Bar. Or in the address bar you can Copy:/Paste about:crashes , about:memory , about:support and more.
You have to set logging options in firefox profile as in developer tips link - https://code.google.com/p/selenium/wiki/DeveloperTips - for console log you should use:
FirefoxProfile p = new FirefoxProfile();
p.setPreference("webdriver.log.file", "/tmp/firefox_console");
WebDriver driver = new FirefoxDriver(p);
For browser log, you should use
webdriver.firefox.logfile
(https://code.google.com/p/selenium/wiki/FirefoxDriver)
Hope this helps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With