- 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
Capturing browser logs with Selenium WebDriver using Java.
We can capture browser logs with Selenium. We have to type cast the RemoteWebDriver to driver and then initialize it. Next, we have to use the setLogLevel method. The import org.openqa.selenium.remote.RemoteWebDriver statement needs to be added in code for the RemoteWebDriver.
Syntax
((RemoteWebDriver) driver).setLogLevel(Level.INFO);
Example
import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.chrome.ChromeDriver; import org.openqa.selenium.remote.RemoteWebDriver import java.util.logging.Level; public class BrwLogs{ public static void main(String[] args) { System.setProperty("webdriver.chrome.driver", "C:\Users\ghs6kor\Desktop\Java\chromedriver.exe"); WebDriver driver = new ChromeDriver(); // Enable logging with setLogLevel method ((RemoteWebDriver) driver).setLogLevel(Level.INFO); driver.get("https://www.tutorialspoint.com/index.htm"); //identify element driver.findElement(By.id("gsc−i−id1")).sendKeys("Selenium"); driver.quit(); } }
Output
- Related Articles
- Clear browser Cookies with Selenium WebDriver Java bindings.
- How to close child browser window in Selenium WebDriver using Java?
- How to launch Edge browser with Selenium Webdriver?
- Switch tabs using Selenium WebDriver with Java.
- Get page title with Selenium WebDriver using Java.
- How to open a browser window in full screen using Selenium WebDriver with C#?
- Selenium WebDriver With Java Quickstart.
- How to scroll down using Selenium WebDriver with Java?
- How to maximize the browser window in Selenium WebDriver using C#?
- How to connect to an already open browser using Selenium Webdriver?
- Using the Selenium WebDriver - Unable to launch chrome browser on Mac
- How to type in textbox using Selenium WebDriver with Java?
- How to get selected option using Selenium WebDriver with Java?
- How to handle authentication popup with Selenium WebDriver using Java?
- How to open browser window in incognito/private mode using python selenium webdriver?

Advertisements