Python Selenium series (i): Introduction and installation of the framework

Source: Internet
Author: User

a selenium What is it?

quoted Baidu Encyclopedia introduction Selenium A passage:

" Selenium is a tool for WEB application testing. the Selenium test runs directly in the browser, just as the real user is doing. Supported browsers include IE(7, 8, 9, ten, one),Mozilla Firefox,Safari,Google Chrome,Opera and so on. The main features of this tool include: Test and browser compatibility -- test your application to see if it works well on different browsers and operating systems. Test system Functions -- Create regression test to verify software functionality and user requirements. Supports automatic recording of actions and automatic generation of test scripts in different languages, such as . Net,Java,and Perl "

Surprisingly , the last word in the language of support did not mention Python, hahaha.

in short, Selenium is used to Web a toolset for automated testing, which enables multi-browser and multilingual development by driving browsers instead of manually completing compatibility testing or functional regression testing .


two selenium and Webdriver What's the relationship?

Webdriver and Selenium were originally two independent projects to implement Web automation. merging the two from Selenium 2, the relationship can be expressed in Selenium 1.0 + webdriver = Selenium 2.0 . currently in the field of testing, what is commonly referred to as selenium is webdriver, whereas Selenium 1 usually refers to selenium RC.

compared to 1.0,the webdriver API is designed to be more concise and simple, driving the browser more efficiently, while addressing the 1.0 In the more difficult to handle some of the application scenarios, such as file upload, download, popup box processing.


three How the Webdriver works

after talking about the relationship between selenium and webdriver , we learn selenium, the actual main is to learn Webdriver API Use the method. However, before this, it is necessary to understand how webdriver works. From the Internet to find a picture, introduce the principle, as follows:

the working principle of Webdriver is summarized as follows:

1. webdriver is designed according to the classic design pattern of client-server;

2. server is remote server, script-initiated browser, its role is to wait for the client to send the request and make the corresponding;

3. The client side is our test code, the Operation command is sent to the server sideby the HTTP request , the server accepts the request, performs the action, and returns information such as execution status, return value, etc. in response;

four selenium Environment Installation

The previous introduction of so many, finally to the topic of this article,the Python development environment How to install selenium?

In fact Selenium installation is very simple, three steps away:

1. Pip Install Selenium
2. Install the browser (chrome)
3. Install the corresponding browser driver (chrome driver) (download the corresponding driver and put it in the Python installation directory)
As mentioned earlier, selenium is a multi-browser support, follow-up I mainly to the Chrome browser as an example of the introduction, other browser installation use is similar. The relationship between the chrome version and the browser-driven version is as follows:
Five Test
Selenium after installation, you need to test whether it can work properly, only a few statements: # Test Selenium installation, selenium can open Chrome browser from selenium import Webdriverbrowser = Webdriver. Chrome () browser.get ("https://www.baidu.com/") print (Browser.title) browser.quit ()
At this point, how to open the browser and automatically access the Baidu Web site, then the installation is normal to complete. For a video explanation of Python selenium introduction and installation of the environment, see: http://i.youku.com/weiworld521 24th.

Python Selenium series (i): Introduction and installation of the framework

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.