Chapter VIII of the statement and branch

@ Statements and expressions

Combinations of data types may constitute statements and expressions, a statement or statements and expressions of a plurality of modules may be formed, different software modules or scripts. Remember this constituent units, as the smallest unit of data types and statements of programming through continuous combined into a variety of software functions and scripts.

The most simple assignment statement

x = 2

 

 Assignments can be applied to tuples, lists and so on.

Conditional statement

The implementation of a certain type of statement that a judge under what conditions; when writing automation scripts, you can put all the features of the next page is written to a function that is called by different methods of operation function parameters; the function will continue to follow talked about.

 

 

 Judge sentences premise is to have a certain condition, and this condition is satisfied in order to execute this statement.

If this condition is not satisfied, you can use elif set a second condition; he was executed in sequence; if the first condition is not met, it will perform the second condition, and so on, to satisfy the conditional execution under this condition.

else behind usage is that the statement is executed under this condition in the case of the previous conditions are not met.

loop statement

 There are cycles for loops and while loops;

The for loop is turn inside out data in a set, the set may be a list, dictionaries, tuples, strings and the like. When writing automation scripts, you can write statements and operating method for loop.

 

 The range function is a built-in function, from 0 starts counting.

We can pass for statements and range statements with assignment statements learned before the operation, the result of such re-assignment, attention, attention indented space for functions which, if aligned with the print statement will be executed each time the statement after the implementation of basis, if the print for alignment with, that would be all the statements for which execution is finished before executing the printer function; different indent the result is not the same.

 

 while statement;

It is a condition of the case ture was performed, while statements in the loop, if conditions become folse will stop execution.

 

 We will determine the conditions for unloading the back while, then use it to judge ture or folse; if it is ture will continue while loop inside the statement or method; if it is folse, just out of the loop.

while loop automation can be used to read the parameter or app automated testing is repeatedly performed one page, the page in order to determine how to achieve the effect.

Nested loop

In the while statement, we can nest other statements, such as if or for statement, and so on.

 

 In fact, before the use of these statements are assignment statements, branching statements and loops combination;

Define a while loop, then do the calculation in this cycle, let him change the value, worth every change, if they meet the following branch statement on the implementation of the method that branch statement; for example, 0 + 1 = 1 satisfy less than 5 , so the implementation of the sentence under the condition; the latter execute the statement continue, this method is out of the current loop executes a loop, if not, will continue execution.

Loop will continue to take on a value calculated, before num becomes 1, by calculation is 1 + 1 = 2, 5, or less than satisfied, continue under this condition statement.

When the added value is greater than five, it will not execute the proviso that the following statement is less than 5.

But performs else the following statement.

In else following a break, this is the termination of the entire cycle; this cycle will not continue to perform the following.

In the automated test, if the test data management is not good, it will change frequently, we can be judged by a while loop meets certain conditions, if certain conditions are met on the implementation of a sentence under this condition; in this way we can improve automation stability script code. The test data also prevent accidental interference.

This small section is completed.

Guess you like

Origin www.cnblogs.com/daodexuke/p/11909178.html
Recommended