- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Getting console.log output from Chrome with Selenium Python API bindings.
We can get console.log output from Chrome with Selenium Python API bindings. We will perform this with the DesiredCapabilities class. We shall enable the logging from the browser with DesiredCapabilities.Chrome setting.
We have to pass this browser capability to the driver object by passing it as a parameter to the Chrome class. To enable logging we shall set the property goog:loggingPrefs of the browser to 'browser':'ALL'.
Syntax
Syntax:dc = DesiredCapabilities.CHROME dc['goog:loggingPrefs'] = { 'browser':'ALL' } driver = webdriver.Chrome(desired_capabilities=dc)
Example
from selenium import webdriver from selenium.webdriver.common.desired_capabilities import DesiredCapabilities #set browser log dc = DesiredCapabilities.CHROME dc['goog:loggingPrefs'] = { 'browser':'ALL' } driver = webdriver.Chrome(executable_path="C:\chromedriver.exe", desired_capabilities=dc) #launch browser driver.get ("https://www.tutorialspoint.com/index.htm") #obtain with get_log() for e in driver.get_log('browser'): print(e) driver.quit()
Output
- Related Articles
- Running Selenium WebDriver python bindings in chrome.
- Getting console.log output from Firefox with Selenium.
- Getting the Standard Output and Standard Error Output Stream through Console in C#
- Clear browser Cookies with Selenium WebDriver Java bindings.
- How to call a JavaScript Function from Chrome Console?
- Log error to console with Web Workers in HTML5
- How to invoke the Chrome browser in Selenium with python?
- Downloading with chrome headless and selenium.
- How to open chrome default profile with selenium?
- How to configure handling and formatting of log file in Selenium with python?
- How to Remove Unicode from Jenkins Console Output logs using Postman?
- How to setup Chrome driver with Selenium on MacOS?
- How to stop a page loading from Selenium in chrome?
- How to Clear the JavaScript Console in Google Chrome
- How to mute all sounds in chrome webdriver with selenium?

Advertisements