Package rjcs; Import org.openqa.selenium.firefox.FirefoxDriver; 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 the try { Driver. .. the 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");. // text box enter Thread.sleep ( 5000 ); driver.findElementById ( "kw") the Clear () ;;. // text box empty Thread.sleep ( 5000 ); driver.findElementById ( . "kw") sendKeys ( "China "); // text box to re-enter driver.findElementById ( " su "). click(); // OK (search) button the Thread.sleep ( 10000 ); } the catch (Exception E) { e.printStackTrace (); } the finally { driver.quit (); } } }