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

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.

主站蜘蛛池模板: 泸州市| 阿城市| 青州市| 长治县| 双流县| 宜兰市| 洪江市| 长阳| 隆回县| 辽中县| 苏州市| 江陵县| 灵宝市| 通化市| 孟连| 敦煌市| 温州市| 库伦旗| 莒南县| 沙湾县| 泗阳县| 蒙山县| 什邡市| 高雄县| 虎林市| 广水市| 民勤县| 宁晋县| 达拉特旗| 鄂州市| 汉沽区| 吉首市| 滦南县| 昌江| 阳江市| 集安市| 房产| 会昌县| 金平| 磴口县| 广东省|