美文网首页
Chrome浏览器启动

Chrome浏览器启动

作者: 红木杉2018 | 来源:发表于2017-03-21 17:14 被阅读0次

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浏览器启动

      本文链接:https://www.haomeiwen.com/subject/rjpgnttx.html