Test Automation For Web-Based Applications

Slides:



Advertisements
Similar presentations
Functions Jay Summet. Aug Functions A function is a piece of code you can use over and over again Treat it like a black box You pass it (optional)
Advertisements

Structured programming
1 Functions Samuel Marateck © A function is a set of statements that can be referred by the function name. To start writing a function. 1. In the.
More Functions CS303E: Elements of Computers and Programming.
Builtins, namespaces, functions. There are objects that are predefined in Python Python built-ins When you use something without defining it, it means.
FUNCTIONS. Function call: >>> type(32) The name of the function is type. The expression in parentheses is called the argument of the function. Built-in.
Python – Part 3 Functions 1. Function Calls Function – A named sequence of statements that performs a computation – Name – Sequence of statements “call”
Functions. Built-in functions You’ve used several functions already >>> len("ATGGTCA")‏ 7 >>> abs(-6)‏ 6 >>> float("3.1415")‏ >>>
Python Functions.
Introduction to Computing Using Python for loop / def- ining a new function  Execution control structures ( if, for, function call)  def -ining a new.
CSC 110 Using Python [Reading: chapter 1] CSC 110 B 1.
Python – Part 3 Functions 1. Getting help Start the Python interpreter and type help() to start the online help utility. Or you can type help(print) to.
Python Let’s get started!.
Xi Wang Yang Zhang. 1. Easy to learn 2. Clean and readable codes 3. A lot of useful packages, especially for web scraping and text mining 4. Growing popularity.
Methods.
LECTURE 2 Python Basics. MODULES So, we just put together our first real Python program. Let’s say we store this program in a file called fib.py. We have.
PYTHON FUNCTIONS. What you should already know Example: f(x) = 2 * x f(3) = 6 f(3)  using f() 3 is the x input parameter 6 is the output of f(3)
 Python for-statements can be treated the same as for-each loops in Java Syntax: for variable in listOrstring: body statements Example) x = "string"
Winter 2016CISC101 - Prof. McLeod1 CISC101 Reminders Quiz 3 next week. See next slide. Both versions of assignment 3 are posted. Due today.
Functions with Arguments and Return Values, Oh My! CS303E: Elements of Computers and Programming.
Python Fundamentals: If Statements and Functions Eric Shook Department of Geography Kent State University.
Lecture III Syntax ● Statements ● Output ● Variables ● Conditions ● Loops ● List Comprehension ● Function Calls ● Modules.
Selenium HP Web Test Tool Training
Reminder About Functions
Python’s Modules Noah Black.
Pseudocode Key Revision Points.
Course A201: Introduction to Programming
Lecture 2 Python Basics.
Python Let’s get started!.
Introduction to Python
COMP 170 – Introduction to Object Oriented Programming
COMPSCI 107 Computer Science Fundamentals
USING ECLIPSE TO CREATE HELLO WORLD
Python’s Modules by E. Esin GOKGOZ.
Selenium WebDriver Web Test Tool Training
Fundamentals of Programming I Managing the Namespace
Functions CIS 40 – Introduction to Programming in Python
Writing modules and packages
Test Automation For Web-Based Applications
PH2150 Scientific Computing Skills
CHAPTER FOUR Functions.
Imperative Programming
Test Automation For Web-Based Applications
CISC101 Reminders Assn 3 due tomorrow, 7pm.
Passing Parameters by value
Object Oriented Programming in Python
Loops CIS 40 – Introduction to Programming in Python
Test Automation For Web-Based Applications
More Looping Structures
Test Automation For Web-Based Applications
Elements of a Python Program
Functions Jay Summet.
Introduction to Value-Returning Functions: Generating Random Numbers
G. Pullaiah College of Engineering and Technology
functions: argument, return value
The structure of programming
COMPUTER PROGRAMMING SKILLS
Functions Jay Summet.
Test Automation For Web-Based Applications
Python Functions.
More Looping Structures
What is a Function? Takes one or more arguments, or perhaps none at all Performs an operation Returns one or more values, or perhaps none at all Similar.
CISC101 Reminders Assignment 3 due today.
Test Automation For Web-Based Applications
def-ining a function A function as an execution control structure
 A function is a named sequence of statement(s) that performs a computation. It contains  line of code(s) that are executed sequentially from top.
Imperative Programming
Functions Jay Summet.
Functions John R. Woodward.
Presentation transcript:

Test Automation For Web-Based Applications Portnov Computer School WebDriver Training Test Automation For Web-Based Applications Presenter: Ellie Skobel

Day 3 Python Modules and Functions

Functions Keyword def introduces a function definition Function name must start with a letter or _ and it's followed by the parenthesized list of formal parameters. Body of the function start at the next line, and must be indented.

Functions def function_name(param1, param2): sum = int(param1) + int(param2) if sum % 2: print sum, ' is an even number' return sum To use the function in your code: function_name(3, 5) function_name(2, 3) sum is an even number nothing printed

This is the correct way: def function_name(param1, param2): sum = int(param1) + int(param2) if sum % 2 == 0: print sum, ' is an even number' return sum

Function's Parameters Possible to define functions with a variable number of parameters (a.k.a arguments) Default Argument Values function can be called with fewer arguments than it is defined to accept Keyword Arguments functions can be called using form kwarg=value Arbitrary Argument Lists function can be called with an any (infinite) number of arguments

Default Argument Values name argument is required age argument is optional False is a default value def register(name, age=None, married=False): print "Welcome", name.title() if age and int(age) > 20: print "You don't look a day over", int(age)–2 if married: print "Your spouse is very lucky!" register("John") register("Jane", 21) register("Bob", 55, True) register("Amy", married=True) register("Ken", age=12, married = False)

Keyword Arguments name argument is required argument form: key = value infinite number of optional arguments def register(name, **kwargs): print "Welcome", name.title() for key in kwargs.keys(): print key, ":", kwargs[key] register("John") register("Jane", age=21) register("Amy", married=True, gender="female") register("Jeff", height="6'1", weight=175, children=None)

Arbitrary Argument Lists name argument is required age argument is optional infinite number of optional arguments def register(name, age=18, *args): print "Welcome", name.title() if age < 18: print "You are underage" for num, arg in enumerate(args): print "Argument #{0} is {1}".format(num, arg) If more that 1 argument given, 2nd one will always be assigned to age register("John") register("Jane", 21) register("Jeff", 21, None) register("Amy", 20, 30, 40, 50, 60) register("Steve", None, 42, "Hello")

Python function definitions Modules A module is a file containing Python definitions and statements The file name is the module name with the suffix .py appended Module name is: common Python statement Python function definitions

Packages Packages are directories which contain python files (modules) Packages are a way of structuring modules The __init__.py files are required to make Python treat the directories as packages python package named: functions contains file: __init__.py regular directory, NOT a package