Java+selenium's HelloWorld

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.