- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
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
Downloading with chrome headless and selenium.
We can download Chrome in headless mode in Selenium. The headless execution is one of the ways saving resources by not utilizing the complete graphical interface.
After the version 59, Chrome can be used in headless mode. The ChromeOptions class is used to modify the default character of the browser. The parameter headless is passed as a parameter to the addArgument method for headless execution.
Syntax
ChromeOptions o = new ChromeOptions(); o.addArguments("headless"); WebDriver driver = new ChromeDriver(o);
Example
Code Implementation.
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.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 creation ChromeOptions o = new ChromeOptions(); //headless argument added o.addArguments("headless"); // add options parameter to Chrome driver WebDriver driver = new ChromeDriver(o); // wait of 5 seconds driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS); driver.get("https://www.tutorialspoint.com/questions/index.php"); // get page title System.out.println("Page title: " + driver.getTitle()); } }
Output
- Related Articles
- Selenium and Headless Environment.
- Downloading a file at a specified location through python and selenium using Chrome driver.
- Downloading file to specified location with Selenium and python.
- How to make firefox headless programmatically in Selenium with python?
- How to trigger headless test execution in Selenium with Python?
- Does Selenium support headless browser testing?
- How to open chrome default profile with selenium?
- How to connect to Chromium Headless using Selenium?
- How to setup Chrome driver with Selenium on MacOS?
- How to invoke the Chrome browser in Selenium with python?
- Getting console.log output from Chrome with Selenium Python API bindings.
- How to mute all sounds in chrome webdriver with selenium?
- Running Selenium WebDriver python bindings in chrome.
- How to launch Chrome Browser via Selenium?
- How to handle chrome notification in Selenium?

Advertisements