- 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
How to get rid of Firefox logging in Selenium?
After the execution of tests, there are logs generated because of Firefox logging in with geckodriver. This log generation by Firefox can be disabled by certain parameters setting.
We can stop these logs from being recorded in the console and capture them in a different file. This is achieved with the help of the System.setProperty method. In the above image, we can see the geckodriver logs generated in the console.
Syntax
System.setProperty(FirefoxDriver.SystemProperty.DRIVER_USE_MARIONETTE, "true"); // turning off logs System.setProperty(FirefoxDriver.SystemProperty.BROWSER_LOGFILE, "<path of file>"); // record logs in another file
Example
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; public class LogsDisable{ public static void main(String[] args) { System.setProperty("webdriver.gecko.driver", "C:\Users\ghs6kor\Desktop\Java\geckodriver.exe"); //logging disable System.setProperty (FirefoxDriver.SystemProperty.DRIVER_USE_MARIONETTE, "true"); //record log in Firefoxlogs.txt file System.setProperty(FirefoxDriver.SystemProperty.BROWSER_LOGFILE, "C:\Users\ghs6kor\Desktop\DebomitaJava\Logs\Firefoxlogs.txt"); WebDriver driver = new FirefoxDriver(); //implicit wait driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS); //URL launch driver.get("https://www.tutorialspoint.com/about/about_careers.htm"); System.out.println("Page loaded"); driver.quit(); } }
Output
Firefoxlogs.txt file
File contents
Advertisements