[Python] Automatic Web Testing Using Python

Source: Internet
Author: User
Automatic Web Testing Using PythonToday, I found a good module that can control ie using Python: pamie. It can open an IE window with a program, fill in the content to be submitted in the program, and can be automatically submitted, and then search for the program execution results from the results returned after the submission. In this way, we can use python to easily write out the Web Automatic Testing Tool ^_^! Official homepage: http://pamie.sourceforge.net/ InstallPamie requires two modules: win32all and ctypes. Download and install them respectively. If you use activepython, you can choose not to install win32all. activepython has been installed by default. If you use python2.5 or a later version, you do not need to install ctypes. Below are two domestic download links: http://down.turbozv.com/develop/python/webtest/ctypes-0.9.9.3.win32-py2.4.exe
Http://down.turbozv.com/develop/python/webtest/pamie20.zip pamiedo not install the program, the required installation is successful, the pamieunzip the zip, the extracted file cpamie. py directly copy to pythonpath/lib can be called. TestWrite the following test code:

#-*-Coding: gb2312
Import cpamie
 
Ie = cpamie. pamie ()
Ie. navigate ("http://www.dormforce.net/Blog/parvel/login.aspx ")
Ie. textboxset ("tbusername", "BT ")
Ie. textboxset ("tbpassword", "he ")
Ie. buttonclick ("btnlogin ")
 
If (true = ie. findtext (Unicode ("illegal Logon", "cp936 "))):
Print "Login Failed! "
Else:
Print "Login OK! "
 
Ie. Quit ()

Run the program. You can see that pamie opens a new ie window, fill in the account and password, submit the window, and finally get the result. The code is very simple. For more information, see Ie = cpamie. pamie () generates an ieie. navigate ("http://www.dormforce.net/Blog/parvel/login.aspx") opens the login interface IE. textboxset ("tbusername", "BT") IE. textboxset ("tbpassword", "he") sets the account and password IE. buttonclick ("btnlogin") submit if (true = IE. findtext (Unicode ("illegal Logon", "cp936"): Check whether "illegal Logon" exists in the returned results. Unicode must be used to search Chinese characters, otherwise, an error occurs. In addition, pamie has many useful functions, such as opening connections and extracting data from tables. For details, see its documentation. For more tutorials, see: http://showmedo.com/videos/series? Name = pythonmarchettipamieseries

 

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.