

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- 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 start ChromeDriver in headless mode?
We can start chromedriver in headless mode. Headless execution is getting popular now−a−days since the resource consumption is less and execution is done at a faster speed.
Post version 59, Chrome supports headless execution. ChromeOptions class is utilized to modify the default characteristics of the browser. The addArguments method of the ChromeOptions class is used for headless execution and headless is passed as a parameter to that method.
Syntax
ChromeOptions opt = new ChromeOptions(); opt.addArguments("headless"); WebDriver drv = new ChromeDriver(opt);
Example
import org.openqa.selenium.WebDriver; import org.openqa.selenium.chrome.ChromeDriver; import org.openqa.selenium.chrome.ChromeOptions; import java.util.concurrent.TimeUnit; public class HeadlessChrome{ public static void main(String[] args) { System.setProperty("webdriver.chrome.driver", "C:\\Users\\ghs6kor\\Desktop\\Java\\chromedriver.exe"); //ChromeOptions object ChromeOptions opt = new ChromeOptions(); //headless argument opt.addArguments("headless"); // configure options parameter to ChromeDriver WebDriver driver = new ChromeDriver(opt); driver.manage().timeouts().implicitlyWait(8, TimeUnit.SECONDS); driver.get("https://www.tutorialspoint.com/about/about_careers.htm"); // get page title System.out.println("Page title in headless mode: " + driver.getTitle()); driver.quit(); } }
Output
- Related Questions & Answers
- How to Run WebDriver in Headless Mode using Postman?
- How to Disable images in Selenium Google ChromeDriver?
- How to connect to Chromium Headless using Selenium?
- How to perform right click using Selenium ChromeDriver?
- Selenium and Headless Environment.
- How to make firefox headless programmatically in Selenium with python?
- How to trigger headless test execution in Selenium with Python?
- Disable images in Selenium Google ChromeDriver.
- How can I control Chromedriver open window size?
- Does Selenium support headless browser testing?
- Downloading with chrome headless and selenium.
- Supervisor Mode (Privileged Mode)
- How to disable landscape mode in Android?
- How to check activity In landscape mode?
- How to check activity in portrait mode?
Advertisements