给新手的代码
package Case;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.ie.InternetExplorerDriver;
import org.openqa.selenium.remote.DesiredCapabilities;
public class Case1 {
public static void main(String[] args) {
System.setProperty("webdriver.ie.driver",
"D:\eclipse\selenium\IEDriverServer.exe");//IEDriverServer.exe的存放路径
WebDriver driver = new InternetExplorerDriver();
driver.get("http://www.baidu.com");
WebElement element = driver.findElement(By.id("kw"));
element.sendKeys("hello world !");
element.submit();
try {
Thread.sleep(5000);
} catch (InterruptedException e) {
e.printStackTrace();
}
System.out.println("Page title is: " + driver.getTitle());
driver.quit();
}
}