- Selenium WebDriver 3 Practical Guide
- Unmesh Gundecha Satya Avasarala
- 134字
- 2021-08-13 16:08:14
Using Headless Mode
Similar to Firefox, we can run tests in headless mode with ChromeDriver. This makes Chrome tests run faster and tests run more efficiently, especially in the CI (Continuous Integration) environment.
We can run Selenium tests in headless mode by configuring the ChromeOptions class as shown in the following code snippet:
@BeforeMethod
public void setup() {
System.setProperty("webdriver.chrome.driver",
"./src/test/resources/drivers/chromedriver");
ChromeOptions chromeOptions = new ChromeOptions();
chromeOptions.setHeadless(true);
driver = new ChromeDriver(chromeOptions);
driver.get("http://demo-store.seleniumacademy.com/");
}
In the preceding code, we first created an instance of the ChromeOptions class, called the setHeadless() method, that passes the value as true to launch the Chrome browser in headless mode. During the execution, you will not see the Chrome window on the screen but the test will be executed in headless mode.
推薦閱讀
- 網(wǎng)絡(luò)云百問百答
- Modern JavaScript Web Development Cookbook
- 物聯(lián)網(wǎng)(IoT)基礎(chǔ):網(wǎng)絡(luò)技術(shù)+協(xié)議+用例
- React Cookbook
- 人人都該都懂的互聯(lián)網(wǎng)思維
- INSTANT LinkedIn Customization How-to
- 設(shè)備監(jiān)控技術(shù)詳解
- Qt5 Python GUI Programming Cookbook
- 深入理解計算機網(wǎng)絡(luò)
- 數(shù)字王國里的虛擬人:技術(shù)、商業(yè)與法律解讀
- 區(qū)塊鏈社區(qū)運營手冊
- 物聯(lián)網(wǎng)商業(yè)設(shè)計與案例
- 深入理解Kubernetes網(wǎng)絡(luò)系統(tǒng)原理
- 5G重塑數(shù)字化未來
- 華為LiteOS:快速上手物聯(lián)網(wǎng)應(yīng)用開發(fā)