Selenium Learning: An example of modular drive testing

Source: Internet
Author: User

Login Module Package file: public.py

#coding =utf-8from selenium import webdriverfrom time import sleepclass  Login ():     #登陆     def user_login (self,driver):         driver.find_element_by_id ("Loginform-username"). Clear ()          driver.find_element_by_id ("Loginform-username"). Send_keys ("91CTT")          driver.find_element_by_id ("Loginform-password"). Clear ()          driver.find_element_by_id ("Loginform-password"). Send_keys ("CTT1106648034")          driver.find_element_by_name ("Login-button"). Submit ()       #退出     def user_logout (self,driver):          driver.find_element_by_link_text ("[Exit]"). Click ()           sleep (5)           driver.quit () 

Test file test22.py

From selenium import webdriverfrom time import sleepfrom public import Logindriver = Webdriver. Chrome () #目的网址: 51cto.comurl = "Http://home.51cto.com/index?reback=http://9603083.blog.51cto.com/9593083/d-2" Driver.get (URL) login (). User_login (Driver) sleep (2) login (). User_logout (Driver)

The login class is defined in file public.py, which contains two function methods, the User_login method, and the User_logout method

Login and exit operation for 51cto.com

File test22.py is the actual operation of the test login and Exit interface

Call the User_login method and the User_logout method by introducing the login class of the module public


Selenium Learning: An example of modular drive testing

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.