Automated testing: Selenium automation environment construction

【Introduction】Selenium is a tool for web application testing. Selenium tests run directly in the browser, just like real users. Supports automatic recording of actions and automatic generation of test scripts in different languages ​​such as .Net, Java, and Perl. This article introduces in detail the tools needed to build an automated testing environment, so that you can learn automated testing without asking for help!

written in front

Tools needed to learn selenium:

1. Browser;

2、Python;

3、Selenium;

4、FireBug(Firefox);

5. Drive chromedriver, IEDriverServer, geckodriver;

6. IDE (Pycharm/Sublime/Eclipse, etc.)

1. Browser

Selenium supports many browsers, so which browser to choose? Which version to choose? Xiaobai recommends using Firefox. Of course, browsers such as Chrome, IE, and Safari are also supported, but the corresponding driver is required.

It is recommended to use Firefox (Firefox browser) here, because it may be difficult for Xiaobai to locate elements in the early stage, and a plug-in firebug is needed, so I am familiar with Firefox before using other browsers.

It doesn't matter whether there is a new version of Firefox or not. The latest version can be used. The required drivers will be mentioned below.

2. Python

Installing Python under Windows is very simple, just install it directly from the official website.

3. Selenium

After the Python environment is set up, it is easy to install selenium. Install selenium directly using pip installation

 pip install selenium

4. Plug-in FireBug

FireBug is a plug-in for viewing code elements of the Firefox browser. It is recommended for beginners to install it. It can quickly locate elements. The focus of selenium is element positioning. Only when it is in place can the next step be performed.

Installation method: Open the Firefox browser, click the button in the upper right corner, click Add-ons, click Extensions, search for firebug, click Install, and restart.

The test installation is successful, press F12 and the following screen appears, indicating that firebug has been installed successfully.

5. Driver installation (under Windows environment)

Firefox:

The new version of Firefox browser needs to install geckodriver driver

Instructions:

1. Download and decompress;

2. Put geckodriver under the python file

3. Add it to the environment variable (for example: G:\Python36\geckodriver.exe)

Chrome:

If you need to use Chrome browser or IE browser, you need the corresponding driver, chromedriver, chromedriver does not have a 64-bit version, 32 can be driven:

Download link: https://npm.taobao.org/mirrors/chromedriver. The method of use is the same as geckodriver.

IE:

IEDriverServer, the link below can download all versions of selenium and IEDriverServer, note that IEDriverServer distinguishes between 32-bit/64-bit:

Download address: http://selenium-release.storage.googleapis.com/index.html. The method of use is the same as geckodriver.

Six, the choice of IDE

The IDE can use the IDLE that comes with python, or some editors, such as Sublime and Pycharm.

Seven, test open the browser

Enter the following code:

# -*- coding: utf-8 -*- from selenium import webdriver driver = webdriver.Firefox() driver.get("https://www.baidu.com")

Open Firefox to browse, and open the Baidu homepage:

END 

meager strength

Finally, I would like to thank everyone who has read my article carefully. Seeing the fans’ growth and attention all the way, there is always a need for reciprocity. Although it is not a very valuable thing, you can take it away if you need it:

These materials should be the most comprehensive and complete preparation warehouse for [software testing] friends. This warehouse has also accompanied tens of thousands of test engineers through the most difficult journey. I hope it can help you too!

 软件测试技术交流群社:110685036(里面还有工作内推机会,毕竟我们是关系社会。)

Software Testing Interview Documentation

We must study to find a high-paying job. The following interview questions are the latest interview materials from first-tier Internet companies such as Ali, Tencent, and Byte, and some Byte bosses have given authoritative answers. Finish this set The interview materials believe that everyone can find a satisfactory job.

How to obtain the above resources:

Guess you like

Origin blog.csdn.net/IT_LanTian/article/details/130170433