Python learning: selenium2 + python3.3.5 Development Environment preparation
Selenium is also a tool for Web application testing. The Selenium test runs directly in the browser, just as the real user is operating. Supported browsers include IE (7, 8, 9), Mozilla Firefox, and Mozilla Suite. The main features of this tool include testing the compatibility with browsers-testing your applications to see if they can work well on different browsers and operating systems. Test System functions-create a regression test to test the software functions and user requirements. Supports automatic recording and Automatic Generation of test scripts in different languages, such as. Net, Java, and Perl. Selenium is an acceptance test tool specially written by ThoughtWorks for Web applications.
For more information about Selenium, see Baidu encyclopedia or wiki. The latest version of selenium is 2.4.5.
This article mainly introduces how to build mac and windows environments. mac is a unix operating system. The installation in this article should also support other linux operating systems.
Preparations for mac system installation:
1. Download python3.3.5 and select 32-bit or 64-bit based on the number of CPU digits of the system. 64-bit: http://www.python.org/ftp/python/3.3.5/python-3.3.5-macosx10.6.dmg 32-bit: http://www.python.org/ftp/python/3.3.5/python-3.3.5-macosx10.5.dmg
2. Download selenium2.45. Https://pypi.python.org/packages/source/s/selenium/selenium-2.45.0.tar.gz
3. Download setuptools. Because Python 3.3.5 does not contain setuptools, it must be installed separately. Https://pypi.python.org/packages/source/s/setuptools/setuptools-14.3.zip#md5=2929b7ebe39ad47f37a25b5a8e66371c
Note: This step is optional. If you have a network, you can install it through the command line and download it automatically.
4. Install Firefox.
Mac system installation:
1. Install python3.3.5. There is no difference between installing python and common software. The above download is dmg. This is not detailed here. After the installation is successful, you can tap python3 in the command line. Because the mac system has the default version of python2, run the python3 command. As follows:
xxx:selenium-2.45.0 fish$ python3Python 3.3.5 (v3.3.5:62cf4e77f785, Mar 9 2014, 01:12:57)[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwinType "help", "copyright", "credits" or "license" for more information.>>>
2. Install setuptools. If you have a network, run the following command:
curl https://bootstrap.pypa.io/ez_setup.py -o - | python3
If there is no network, use the downloaded file for installation. Run the following command:
tar -zxvf setuptools-14.3.zipcd setuptools-14.3python3 setup.py install
Note: here you need to use the python3 command, for other system installation, you can refer to the https://pypi.python.org/pypi/setuptools
3. Install selenium2.4.5
tar -zxvf selenium-2.45.0.tar.gzcd selenium-2.45.0python3 setup.py install
4. Install Firefox.
5. Test the script. Write the following script and save it as hellobaidu. py.
From selenium import webdriverimport timedriver = webdriver. firefox () driver. get ("http://www.baidu.com") driver. find_element_by_id ("kw "). send_keys ("python programming and development") driver. find_element_by_id ("su "). click () time. sleep (5) # Wait for 5 s to close the browser. Driver. quit ()
After saving, execute python3 hellobaidu. py and check the effect. Is that all done ?! The detailed description will be discussed later.