- 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 Firefox with Selenium.
We can get console.log output from Firefox with Selenium. This is done with the setProperty method.FirefoxDriver.SystemProperty.BROWSER_LOGFILE and the path of the file in which the logs are to be captured are passed as parameters to that method.
Syntax
System.setProperty(FirefoxDriver.SystemProperty.BROWSER_LOGFILE, "FFLogs.txt");
After refreshing the project folder, we shall get the FFLogs.txt file where the logs shall be captured.
Example
Code Implementation.
import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.firefox.FirefoxDriver; import java.util.concurrent.TimeUnit; import org.openqa.selenium.logging.LogType; public class FirefoxLogs{ public static void main(String[] args) { System.setProperty("webdriver.gecko.driver", "C:\Users\ghs6kor\Desktop\Java\geckodriver.exe"); // set the System Property to BROWSER_LOGFILE and path of log file System.setProperty(FirefoxDriver.SystemProperty.BROWSER_LOGFILE, "FFLogs.txt"); WebDriver driver = new FirefoxDriver(); driver.get("https://www.tutorialspoint.com/tutor_connect/index.php"); driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS); // identify element driver.findElement(By.id("txtSearchText")).sendKeys("Selenium"); driver.quit(); } }
Output
A log file with the name FFLogs.txt gets created within the project folder.
- Related Articles
- Getting console.log output from Chrome with Selenium Python API bindings.
- Getting the Standard Output and Standard Error Output Stream through Console in C#
- Log error to console with Web Workers in HTML5
- Which version of Firefox is compatible with selenium
- How to Remove Unicode from Jenkins Console Output logs using Postman?
- How to invoke the Firefox browser in Selenium with python?
- Handle Firefox Not Responding While Using Selenium WebDriver With Python?
- How to make firefox headless programmatically in Selenium with python?
- How to get Firefox working with Selenium WebDriver on Mac OSX?
- How to hide Firefox window (Selenium WebDriver)?
- How to get Exception log from a console and write it to external file in java?
- Access to file download dialog in Firefox in Selenium.
- How does Selenium Webdriver handle SSL certificate in Firefox?
- How to set Proxy in Firefox using Selenium WebDriver?
- How to get rid of Firefox logging in Selenium?

Advertisements