官术网_书友最值得收藏!

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.

主站蜘蛛池模板: 馆陶县| 三江| 化隆| 余姚市| 盱眙县| 辽源市| 彭泽县| 微山县| 原阳县| 京山县| 辽中县| 高尔夫| 舟曲县| 镇远县| 常德市| 彰武县| 韶关市| 长白| 新田县| 包头市| 崇左市| 庆元县| 工布江达县| 搜索| 固始县| 岳普湖县| 新兴县| 剑阁县| 广宗县| 综艺| 公主岭市| 靖西县| 碌曲县| 罗城| 明星| 泽普县| 阜平县| 通榆县| 兴海县| 从化市| 长子县|