package rjcs; import java.util. * ; import org.openqa.selenium.WebElement; import org.openqa.selenium.firefox.FirefoxDriver; import org.openqa.selenium.interactions.Actions; import org.openqa.selenium.support.ui.Select; public class xinkaishi { public static void main(String[] args) { System.setProperty ( "webdriver.firefox.bin", "C: \\ Program Files (the x86) \\ \\ firefox.exe the Mozilla Firefox"); // set the installation path Firefox, preventing system can not find FirefoxDriver Driver = new new FirefoxDriver (); // initialize FireFox browser instance, and open the browser try { . driver.manage () window () the Maximize ();. // maximize the window Thread.sleep ( 5000 ); driver.navigate().to("http://www.baidu.com"); Thread.sleep(5000); driver.findElementById ( . "kw") sendKeys ( "China United States" ); System.out.println(driver.findElementById("kw").getAttribute("value")); Thread.sleep(10000); }catch (Exception e) { e.printStackTrace (); }finally { driver.quit(); } } }
Results of the:
China America