Web Automation test Environment build 1 (based on Firefox Firefox browser)

Source: Internet
Author: User
Tags testng

Automation testing is the trend of the times, so many testers began to study automated testing, Web Automation testing test is not difficult, but many people are blocked in the environment to build this step, behind the study of passion, here, Tao Brother teach you to build a Firefox browser under the automated test environment (based on Java).

Why is it difficult to build an automated test environment, because of the high environmental requirements, the selenium version, the driver file version, the browser version of this has an adaptation problem, if you do not pay attention to these version information, it may cause the Web Automation program will not run up.

Here is a demonstration of the Selenium 3.x Firefox automated automation environment setup:

  1. Prepare the dependency information under Selenium 3.5.1,maven as follows:

  

      <Dependency>        <groupId>Org.seleniumhq.selenium</groupId>        <Artifactid>Selenium-java</Artifactid>        <version>3.5.1</version>      </Dependency>    

  2. Prepare Firefox driver file Geckodriver.exe(starting from Selenium 3.0, the automation of Firefox will need to drive the file to drive), The driver files prepared here are version 0.19.0, you can go to selenium official website to download, or directly use the teacher to share the network address to download "Link: https://pan.baidu.com/s/1oN8tg66cobM7yX-T6GKuFw Password: 9rb7"

  

In addition, we remember to change the version of Firefox to 56 (and prohibit the browser update function , prevent the browser background automatically update version, as to how to prohibit, very simple things, pls self-baidu), because according to the Geckodriver changes log proposal, The 0.19.0 version of the driver is best suited for: Firefox 55.0 (or higher) + Selenium 3.5 (or higher), which is why the above uses the selenium3.5.1.

  

Here are the download links for all the versions of Firefox: "http://ftp.mozilla.org/pub/firefox/releases/", or you can go directly to my disk download: "Link: https://pan.baidu.com/s/ 1xmbkf_viiv_ryfgn2v-qaw Password: Eyo6 "

  

  3. Verification Code

  

 PackageWeb.demo;ImportOrg.openqa.selenium.WebDriver;ImportOrg.openqa.selenium.firefox.FirefoxDriver;ImportOrg.testng.annotations.AfterClass;ImportOrg.testng.annotations.BeforeClass;Importorg.testng.annotations.Test;/**Firefox's automated test environment setup *@authorNickjiang **/ Public classFirefoxauto {webdriver driver; @BeforeClass Public voidinit () {System.setproperty ("Webdriver.gecko.driver", "Src/test/resources/geckodriver.exe"); Driver=NewFirefoxdriver (); } @Test Public voidTest () {Driver.get ("Http://www.baidu.com"); System.out.println ("Open the website and wait 3 seconds before closing"); Try{Thread.Sleep (3000); } Catch(Exception e) {e.printstacktrace (); }} @AfterClass Public voidteardown () {driver.quit (); }}

Drive file storage directory: Src/test/resources/geckodriver.exe, such as:

  4. The effect is as follows, which means the environment is done:

At this point, the Firefox automated test environment based on the Java+selenium 3.x is ready. Java+selenium 2.x later will be added for everyone. The next article will bring you the chrome under the automation environment to build.

Web Automation test Environment build 1 (based on Firefox Firefox browser)

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.