
- 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 Run WebDriver in Headless Mode using Postman?
We can run webdriver in headless mode. This is achieved with the HTMLUnitDriver which is the fastest webdriver among all the other browser drivers.
Post Selenium 2.53 version, the HTMLUnitDriver jar should be added explicitly in the project. To add the required dependency, the below steps need to be followed −
Navigate to − https://github.com/SeleniumHQ/htmlunit-driver/releases.
Click on the jar marked in the below image.
Right-click on the project and choose the option Build path. Then click on Configure Build Path.
Click on Java Build Path and select the Libraries tab. Click on the Add External JARs button. Then add the downloaded HTMLUnitDriver jar. Finally, click on the Apply and Close button.
In our code, we have to add the import statement org.openqa.selenium.htmlunit.HtmlUnitDriver for the HTMLUnitDriver.
Code Implementation
import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import java.util.concurrent.TimeUnit; import org.openqa.selenium.htmlunit.HtmlUnitDriver; public class HeadlessModeHTMLUnit{ public static void main(String[] args) { //HtmlUnitDriver instance HtmlUnitDriver driver = new HtmlUnitDriver(); // implicit wait driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS); //URL launch driver.get("https://www.tutorialspoint.com/questions/index.php"); System.out.println("Page title: " + driver.getTitle()); driver.quit(); } }
Output
- Related Questions & Answers
- How to start ChromeDriver in headless mode?
- How to run Collection Runner in Postman?
- How to Run Postman Collection on Jenkins using Newman Commands?
- Run Postman Collection on Jenkins
- How to Use WebDriver Javascript Executor to Navigate to a URL using Postman?
- How to run Selenium WebDriver test cases in Chrome?
- How to connect to Chromium Headless using Selenium?
- How to open browser window in incognito/private mode using python selenium webdriver?
- How can we run MySQL statements in batch mode?
- How to set Tests using Functional Method in Postman?
- How to run .SQL script using JDBC?
- Selenium and Headless Environment.
- How to Generate Newman Reports on Jenkins using Postman?
- How to Verify Tooltip using Selenium WebDriver?
- How to upload files using Selenium Webdriver?