package com.gyee.wisdom.report.controller;


import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;

import java.time.Duration;

public class TestController {

    private final static String driver = "webdriver.chrome.driver";
    private final static String chromeDriver = "C:\\Program Files\\Google\\Chrome\\Application\\chromedriver.exe";

    public static void main(String[] args) {
        try {
            System.out.println("打开浏览器进行操作");
            System.setProperty(driver,chromeDriver);
            //获取控制 打开浏览器
            WebDriver driver = new ChromeDriver();
            driver.manage().window().maximize();//浏览器最大化
            //超时等待30秒
            Duration duration = Duration.ofSeconds(30);
            driver.manage().timeouts().implicitlyWait(duration);
            //跳转到百度浏览器
            driver.get("http://www.baidu.com/");
            //操作浏览器 获取到输入框
            WebElement kk = driver.findElement(By.id("kw"));
            //然后向百度输入框输入selenium java
            kk.sendKeys("如也");
            //通过元素属性id=su找到百度一下搜索按钮
            WebElement btn = driver.findElement(By.id("su"));
            //对按钮进行点击操作
            btn.click();
        }catch (Exception e){
            e.printStackTrace();
        }


    }


}
