配置参考文章 点击打开链接
记录下导入和结构
package com.selenium.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.*;
public class TestHelloWorld {
public static void main(String[] args){
WebDriver driver = new FirefoxDriver();
driver.get("http://www.baidu.com/");
driver.manage().window().maximize();
WebElement txtbox = driver.findElement(By.name("wd"));
txtbox.sendKeys("自动化测试");
WebElement btn = driver.findElement(By.id("su"));
btn.click();
driver.close();
}
}