Install jdk (jdk config environment variable) eclipse(free to install)
Install Google Chrome Download chorme driver (chorme driver also configure the environment variable to configure the chormedriver.exe Path to the path behind, e.g. d:/chromedriver/chromedriver.exe; )
launch Eclipse to create a new Java project, import the selenium webdriver jar package, in the command window as an administrator Verify that the jar is correct and enter the following command
Verify the build is successful with the following applet
Public Static void Main (string[] args) {
TODO auto-generated Method stub
System. SetProperty ("Webdriver.chrome.driver", "D:/chromedriver/chromedriver.exe");
Webdriver wd=New chromedriver ();
Wd.get ("https://www.baidu.com");
Wd.manage (). Timeouts (). implicitlywait (10,timeunit. SECONDS);
if (Wd.findelement (by. ID("kw")). Isdisplayed ()) {
System. out. Print ("66666");
Wd.findelement (by. ID("kw")). SendKeys ("Selenium");
Wd.findelement (by. ID("su")). Click ();
}Else{
System. out. Print ("5555");
}
Try {
System. out. Print ("true");
}
Catch (Exception e) {
System. out. Print ("Erro");
}
Wd.close ();
}
Selenium+java+chrome Automated test Environment setup