Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Prepared By
Naveenraj Soundararajan
2
ntroduction
Selenium is a tool used for functional and regression testing of
web applications.
Works with any browser that supports Javascript
Can simulate a user navigation through pages and then assert for
specific marks on the pages
SeIenium Components
Selenium IDE - To create and debug test scripts
Selenium Remote Control - To run the test on many browsers like
Internet Explorer, Firefox , Chrome and to modify the test
programmatically
Selenium Grid - To run the tests parallely on multiple machines at
the same time
SeIenium Features
CPAN Comprehensive Perl Archive network
One stop shop for perl
t is an archive of over 16,000 perl modules, as well as documentation for it
The CPAN's main purpose is to help programmers locate modules and
programs not included in the Perl standard distribution
Weblink
http://www.cpan.org/
http://www.perl.com/CPAN/
4
5
#unning PerI Scripts #unning PerI Scripts
Windows
Download ActivePerl from ActiveState
Just run the script from a 'Command Prompt' window
perl script_name
&NX
Put the following in the first line of your script
#!/usr/bin/perl
Run the script
% perl script_name
SampIe program
example.pl
#! /usr/sbin/perl
# sample program
$name = <STDN> ; # getting the input from keyboard
chomp ($name);
print "Welcome $name to perl; # printing it on screen
Basic syntax
All the executable statements should end with semi colon
Comments should start with pound sign '#'
No multi line comments in Perl
You don't have to declare a variable before you access it and don't have to
declare a variable's type
utput / input
Print ( ) to print text on the screen
Examples
print "hello world \n ; # hello world followed by new line
a = "perl;
print "Welcome $a; => Welcome perl
print "Welcome \$a; => Welcome $a
Say ( ) - Appends \n at the end
<STDN> - Getting in from keyboard ( like scanf in C)
$a = <STDN>;
scape Sequences
ScaIars
Scalar variables stores single value, a string or number
Scalar Variable Syntax
Variable name starts with $, followed by at least one letter, which is
followed by any number of letters, digits, or underscore characters
ex: $sample_data1 = "test;
$sample_data2 = 5 ;
Variable names are case sensitive
$VAR , $var, $Var - Treated as different variables
Strings
Quoting Strings
With SingIe quotes Special meaning of the characters with single quotes
are not interpreted by perl
ex: $lang = "perl " ;
print 'Learning $lang'; # ouput - Learning $lang
With oubIe quotes Special meanings of characters with in double
quotes are interpreted by perl
ex: $lang = "perl " ;
print "Learning $lang; # ouput - Learning perl
2
String operators
perator peration
. (Dot) string concatenation
x string repetition
.= concatenation and assignment
$string1 = "potato";
$string2 = "head";
$newstring = $string1 . $string2; #"potatohead"
$newerstring = $string1 x 2; #"potatopotato"
$string1 .= $string2; #"potatohead"
4
NumericaI operators
perators peration
Addition
-
Subtraction
*
Multiplication
/
Division
=
Assignment
**
Exponentiation
%
Modulo operator
Auto increment
--
Auto decrement
uto conversion b/w num and string
Perl automatically converts between numbers and strings depends on the
operator being used on the scalar value
Examples:
"12 * "3 = 36
"12fred * "3 = 36
"12fred2 * "3 = 36
"fred * "3 = 0
"Fred3 * "3 =0
"fred.3 = fred3
5
Bit manipuIation operators
perator peration
Bitwise AND
| Bitwise OR
^ Bitwise XOR
~ Bitwise NOT
>> Right shift operator
<< Left shift operator
Comparison perators Comparison perators
String peration rithmetic
t less than
t greater than >
eq equal to ==
e less than or equal to =
e greater than or equal to >=
ne not equal to !=
cmp compare, return 1, 0, -1 =>