The automatic test model of "python-"--parameterization

Source: Internet
Author: User

First, the automation test code at the beginning is linear, followed by the development of modular code, so involves the functions and methods of reference.

1. The most important differences between functions and methods:

When defining a function in a Python method, the function must write self. When you define a function individually, you do not need to write self. In Java, Self is invisible and does not need to be written out, but it must be written in Python.

  #login  method defines a function fun ()   
1 class login (): 2 def Fun (self,a,b): 3 c=a+b 4 return c 5 6 d=login () 7 f=d.fun (4,5 8 print (f) 9
1 # Define a function fun () individually 2 class login (): 3      def Fun (A, b): 4          c=a+b5          print(c)

2. Logging out of the module

If the log-in exit above does not add driver=self.driver, the reference is to its own driver (that is, the driver). Then each of the following sentences will need to add self to the driver reference. To be able to find the object Oh.

Modular login.py Files:

Total Files:

The automatic test model of "python-"--parameterization

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.