Chrome浏览器启动

package com.selenium.gen;

import org.openqa.selenium.By;

import org.openqa.selenium.WebDriver;

import org.openqa.selenium.chrome.ChromeDriver;

import org.openqa.selenium.chrome.ChromeOptions;

public class ChromeTest {

public static void main(String[] args) {

// TODO Auto-generated method

ChromeOptions options=new ChromeOptions();

//您使用的是不受支持的命令行标记:--ignore-certificate-errors。稳定性和安全性会有所下降,设置

options.addArguments("--start-maximized", "allow-running-insecure-content", "--test-type");

// options.addArguments("--user-data-dir=C:\\Users\\user\\AppData\\Local\\Google\\Chrome\\User Data\\Default");

ChromeDriver driver=new ChromeDriver(options);

driver.get("https://www.baidu.com");

driver.findElement(By.xpath("//input[@id='kw']")).sendKeys("1234");

driver.findElement(By.id("su")).click();

System.out.println(driver.getTitle());

// driver.quit();

}

}

你可能感兴趣的:(Chrome浏览器启动)