Test courses at school, access to automated management tools, and work with teaching assistants to change jobs, so think about learning selenium, a powerful web automation tool.
1.lenium official website: http://www.seleniumhq.org/Download the Selenium installation package here, I downloaded the selenium-java-3.8.0. The specific selenium version number is not very clear, it should be selenium2 (also known as Selenium webdriver)
2. Download chrome and the corresponding chromedriver.
Chrome version Number: 62.0.3202.89 (official version) (64-bit)
Chromedriver Version Number: 2.33
Corresponding relational tables and: http://blog.csdn.net/huilan_same/article/details/51896672
3. After doing the work, open Eclipse and import Selenium-server-standalone-3.8.0.jar
You can do this by typing in the code.
/*** This is a java+selenium HelloWorld * function: Open the browser, enter the Baidu home page, enter the relevant content and search *@authorHey_boom*/Importorg.openqa.selenium.By;ImportOrg.openqa.selenium.WebDriver;Importorg.openqa.selenium.WebElement;ImportOrg.openqa.selenium.chrome.ChromeDriver; Public classhelloworld{ Public Static voidMain (string[] args)throwsexception{//Setting the CHROMEDRIVER environment variable pathSystem.setproperty ("Webdriver.chrome.driver", "c:/users/zcer/appdata/local/google/chrome/application/ Chromedriver.exe "); //Create a Chromedriver objectWebdriver driver=NewChromedriver (); //Maximize the formdriver.manage (). window (). Maximize (); //Get URLDriver.get ("https://www.baidu.com"); //By ID Get element text input boxWebelement elementinput= driver.findelement (by.id ("kw"))); Thread.Sleep (1000); Elementinput.sendkeys ("Selenium+java"); Elementinput.submit (); //stay on page for three secondsThread.Sleep (3000); Driver.close (); Driver.quit ();//The Quit () method closes the browser }}
4. It is important to note that the relevant documents can be consulted on the website to enhance the understanding of selenium. Here is an introduction to the Chinese SELENUIM2 API:
Https://www.cnblogs.com/puresoul/p/3477918.html
Java+selenium's HelloWorld