Your SlideShare is downloading. ×
Foundation Selenium
Webdriver (java)
2 days training
Who is the training for?
•

Ideal for manual testers wanting to move into
automation testing

•

No programming knowledge ...
High level
•
•
•

•

TestNG and jUnit

Selenium configuration

•

ANT

•

Cross Browser
XPATHS and CSS Selectors

•

•

Sel...
What will you learn?
•

Selenium overview and configuration

•

Test Frameworks - testNG and jUnit
Frameworks

•

Selenium ...
schedule
Day 1

Day 2

•

Selenium IDE and RC

•

Webdriver

•

Java

•

jUnit and testNG

•

Java OOP

•

cross browser

...
What’s new?
“We have raised the learning bar for our foundation level
training with more emphasis on Selenium Webdriver an...
Environment
overview
•

Eclipse IDE

•

JDK - versions

•

Java version

•

Maven

•

installation and configuration

!8

www.time2test...
download and use

•

We need to use many different software
components on a variety of different hardware and
operating sy...
Eclipse IDE

•

Editor

•

Let the magic of Eclipse help with programming

!10

www.time2test.co.uk
maven
•

manages the software package dependencies and
versions.

•

we will use Eclipse’s built in maven support

•

can ...
maven

•

dependencies

•

pom file

!12

www.time2test.co.uk
Java
Aim
•

Aim is to learn enough Java for Testers that will
allow you to develop Webdriver test scripts.

•

too much detail ...
overview
•

Variables

•

Functions

•

Loops

•

Constructors

•

Interfaces

!15

www.time2test.co.uk
High level terms
•

objects - has behaviours/states - a web page has
states - links, buttons, forms, images and
behaviours...
Basics
•

case sensitive

•

class names - start with upper case

•

method names - start with lower case

•

saving files ...
Basics 2
•

java identifiers - variables, classes, methods use names - begin with
character or underscore

•

java modifiers...
java keywords
abstract

assert boolean

break byte

case catch char

class const continue default do doubleelse
final

final...
Say Hello
•

Very First Java Program

•

what does it mean?

!
public class HelloWorld {	
!
	 public static void main(Stri...
simple case study
•

class

•

objects

•

constructors

•

instance variables

!21

www.time2test.co.uk
Date

Date d = new Date();
// will give you the date and time

!22

www.time2test.co.uk
variables
•

integer

•

double

•

string

•

char

!23

www.time2test.co.uk
methods - functions
•

without a return value - void

•

with return values

•

take inputs as parameters

!24

www.time2t...
arrays
•

integer array

•

string array

•

object array

!25

www.time2test.co.uk
multi arrays

String x[][] = new String[3][4];

!26

www.time2test.co.uk
conditions

•

greater than, less than… > ,< , <=, >=, !

•

comparators - and &&, or ||, equals ==

!27

www.time2test.co...
statements
•

if , then ,

•

if, then, else if

•

switch statement

!28

www.time2test.co.uk
loops
•

while

•

for

•

do while

!29

www.time2test.co.uk
loops - while
•

while(expression)

•

{
//block of code to run

•
•

}

!30

www.time2test.co.uk
loops - for
•

for(initialization; expression; update_statement)

•

{
//block of code to run

•
•

}

!31

www.time2test....
loops - do while
•

do

•

{

•
•

//block of code to run
} while(expression);

!32

www.time2test.co.uk
random

•

Random inputs for forms based testing

!33

www.time2test.co.uk
exceptions example

•

catch those exceptions and print them out

!34

www.time2test.co.uk
comments

•

multiple /* */

•

single line //

!35

www.time2test.co.uk
Java OOP
overview
•
•

constructors

•

inheritance

•

packages

•

getter and setter
methods

objects

•

•

class

exceptions
!3...
class

// field, constructor, and
// method declarations

!38

www.time2test.co.uk
constructors

Constructor declarations look like method declarations—except that they use
the name of the class and have n...
getter and setter methods

•

Define methods which allow you to read the values
of the instance variables and to set them. ...
objects

A typical Java program creates many objects, which interact by invoking
methods.

!41

www.time2test.co.uk
overriding

If a class inherits a method from its super class, then there is a chance to
override the method provided that...
inheritance

•

class extends an existing class

!43

www.time2test.co.uk
encapsulation

•

encapsulation is also referred to as data hiding.

!44

www.time2test.co.uk
abstraction

•

Abstraction refers to the ability to make a class
abstract in OOP. An abstract class is one that
cannot be...
interfaces

An interface is a collection of abstract methods. A class implements an
interface, thereby inheriting the abst...
polymorphism

Polymorphism is the ability of an object to take on many forms. The most
common use of polymorphism in OOP o...
packages

•

folder structure

!48

www.time2test.co.uk
exceptions
•

Large topic area - lets focus on what we need for
web driver and appreciate high level
•

try

•

catch

•

...
try - catch

•

Do something and attempt to catch the exception.

•

View the java docs to see what type of exceptions
can...
enum
•

An enum type is a special data type that enables for a variable to be a set of
predefined constants.

•

Use them ...
jUnit
overview
•

background

•

integration with Eclipse

•

notation

•

assertions

•

maven

•

examples
!53

www.time2test....
notation
•

@Test - Mark your test cases with @Test annotations

•

@Before and @After - use for “setup” and
“tearDown” me...
Assertions
•

assertEquals([String message], expected, actual) - Tests that two values are
the same. Note: for arrays the ...
testNG
overview
•

integration with Eclipse

•

notation

•

maven

•

examples

•

@DataProvider and @Parameters

•

differences...
annotations
•

@BeforeClass - oneTimeSetUp

•

@BeforeMethod - setUp

•

@Test - testEmptyCollection

•

@AfterMethod - te...
@Parameters

•

xml files to grab parameters for tests

!59

www.time2test.co.uk
@DataProviders

•

test data as inputs

!60

www.time2test.co.uk
Test Results

TestNG by default generates a different type of report for its test execution.
This includes an HTML and an ...
ant
overview
•

what is ant?

•

command line usage

•

benefits

•

ant and testNG

!63

www.time2test.co.uk
Webdriver
overview

•

more details coming soon

!65

www.time2test.co.uk
locating webelements
overview

•

more details coming soon

!67

www.time2test.co.uk
alerts and cookies
overview

•

more details coming soon

!69

www.time2test.co.uk
wait strategies
overview

•

more details coming soon

!71

www.time2test.co.uk
cross browser
overview

•

more details coming soon

!73

www.time2test.co.uk
data driven

•

Excel spreadsheets or CSV files to seed your tests

!74

www.time2test.co.uk
know how
overview

•

more details coming soon

!76

www.time2test.co.uk
Selenium IDE and RC
overview
•

Selenium IDE!
•
•

javascript functions and random variables

•
•

install and use

record and playback

Selen...
Jenkins
overview
•

more details to follow

!80

www.time2test.co.uk
Conclusions
goals and objectives
•

Review your goals.

•

Have we met your expectations?

•

Email us and we will setup a follow up S...
Thank you

•

From the Time2test Team

!83

www.time2test.co.uk
Upcoming SlideShare
Loading in...5
×

Foundation selenium java

3,248

Published on

Foundation Selenium Java Course

Published in: Technology
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
3,248
On Slideshare
0
From Embeds
0
Number of Embeds
5
Actions
Shares
0
Downloads
2
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

Transcript of "Foundation selenium java "

  1. 1. Foundation Selenium Webdriver (java) 2 days training
  2. 2. Who is the training for? • Ideal for manual testers wanting to move into automation testing • No programming knowledge required • Testers involved with website testing • Testers wanting to gain technical skills !2 www.time2test.co.uk
  3. 3. High level • • • • TestNG and jUnit Selenium configuration • ANT • Cross Browser XPATHS and CSS Selectors • • Selenium overview • • Firebug and Firepath • Website testing Selenium IDE Selenium RC Java for Selenium • Java OOP concepts • Forms and Webdriver • Eclipse IDE and Maven • Excel and Webdriver !3 www.time2test.co.uk
  4. 4. What will you learn? • Selenium overview and configuration • Test Frameworks - testNG and jUnit Frameworks • Selenium IDE ( user extensions, record, playback, JavaScript, IDE to Webdriver) • ANT integration with Webdriver • Cross Browser testing using Webdriver • XPATHS and CSS location strategies • Firebug and Firepath • Website testing using Webdriver ( hyperlinks, Buttons, Input boxes, attachments) • Forms and Webdriver • Excel and Webdriver • • • • Selenium RC ( cross browser testing, start and stop, command line usage ) Java for Selenium (SDK, features, variables, functions, loops, constructors, interfaces) Java OOP concepts (Class, Objects in Java, Inheritance in Java, Java Packages, exception handling) Eclipse IDE ( download, versions, common jars, installation) and MAVEN !4 www.time2test.co.uk
  5. 5. schedule Day 1 Day 2 • Selenium IDE and RC • Webdriver • Java • jUnit and testNG • Java OOP • cross browser • Environment • xpaths and css • Eclipse and Maven • firebug and firepath !5 www.time2test.co.uk
  6. 6. What’s new? “We have raised the learning bar for our foundation level training with more emphasis on Selenium Webdriver and Java.” • More focus on Webdriver API • More focus on Java for Web-driver • Less focus on Selenium IDE and Selenium RC • More focus on ANT and jUnit !6 www.time2test.co.uk
  7. 7. Environment
  8. 8. overview • Eclipse IDE • JDK - versions • Java version • Maven • installation and configuration !8 www.time2test.co.uk
  9. 9. download and use • We need to use many different software components on a variety of different hardware and operating systems. !9 www.time2test.co.uk
  10. 10. Eclipse IDE • Editor • Let the magic of Eclipse help with programming !10 www.time2test.co.uk
  11. 11. maven • manages the software package dependencies and versions. • we will use Eclipse’s built in maven support • can be used via command line !11 www.time2test.co.uk
  12. 12. maven • dependencies • pom file !12 www.time2test.co.uk
  13. 13. Java
  14. 14. Aim • Aim is to learn enough Java for Testers that will allow you to develop Webdriver test scripts. • too much detail at the Java level will deter you from moving to Webdriver. !14 www.time2test.co.uk
  15. 15. overview • Variables • Functions • Loops • Constructors • Interfaces !15 www.time2test.co.uk
  16. 16. High level terms • objects - has behaviours/states - a web page has states - links, buttons, forms, images and behaviours like form submission, link navigation • class - blueprint that describes behaviours/states for an object • methods - are behaviours • instance variables - values assigned to instance variables !16 www.time2test.co.uk
  17. 17. Basics • case sensitive • class names - start with upper case • method names - start with lower case • saving files - save as the class name ( eclipse will do this) • main() - mandatory for java program ( not if you use jUnit) !17 www.time2test.co.uk
  18. 18. Basics 2 • java identifiers - variables, classes, methods use names - begin with character or underscore • java modifiers • • • access - default, protected, private, public non access - final, abstract java variables • local • class ( static) • instance ( non static) !18 www.time2test.co.uk
  19. 19. java keywords abstract assert boolean break byte case catch char class const continue default do doubleelse final finally float instanceof for goto if int interface long enum extend implements import native newpackage private protected public return short static strictfp super switch synchronized this transient try void !19 throw throws volatilewhile www.time2test.co.uk
  20. 20. Say Hello • Very First Java Program • what does it mean? ! public class HelloWorld { ! public static void main(String[] args) { ! System.out.println("Hello to java for Webdriver"); } ! } !20 www.time2test.co.uk
  21. 21. simple case study • class • objects • constructors • instance variables !21 www.time2test.co.uk
  22. 22. Date Date d = new Date(); // will give you the date and time !22 www.time2test.co.uk
  23. 23. variables • integer • double • string • char !23 www.time2test.co.uk
  24. 24. methods - functions • without a return value - void • with return values • take inputs as parameters !24 www.time2test.co.uk
  25. 25. arrays • integer array • string array • object array !25 www.time2test.co.uk
  26. 26. multi arrays String x[][] = new String[3][4]; !26 www.time2test.co.uk
  27. 27. conditions • greater than, less than… > ,< , <=, >=, ! • comparators - and &&, or ||, equals == !27 www.time2test.co.uk
  28. 28. statements • if , then , • if, then, else if • switch statement !28 www.time2test.co.uk
  29. 29. loops • while • for • do while !29 www.time2test.co.uk
  30. 30. loops - while • while(expression) • { //block of code to run • • } !30 www.time2test.co.uk
  31. 31. loops - for • for(initialization; expression; update_statement) • { //block of code to run • • } !31 www.time2test.co.uk
  32. 32. loops - do while • do • { • • //block of code to run } while(expression); !32 www.time2test.co.uk
  33. 33. random • Random inputs for forms based testing !33 www.time2test.co.uk
  34. 34. exceptions example • catch those exceptions and print them out !34 www.time2test.co.uk
  35. 35. comments • multiple /* */ • single line // !35 www.time2test.co.uk
  36. 36. Java OOP
  37. 37. overview • • constructors • inheritance • packages • getter and setter methods objects • • class exceptions !37 www.time2test.co.uk
  38. 38. class // field, constructor, and // method declarations !38 www.time2test.co.uk
  39. 39. constructors Constructor declarations look like method declarations—except that they use the name of the class and have no return type !39 www.time2test.co.uk
  40. 40. getter and setter methods • Define methods which allow you to read the values of the instance variables and to set them. These methods are called setter and getter. !40 www.time2test.co.uk
  41. 41. objects A typical Java program creates many objects, which interact by invoking methods. !41 www.time2test.co.uk
  42. 42. overriding If a class inherits a method from its super class, then there is a chance to override the method provided that it is not marked final. !42 www.time2test.co.uk
  43. 43. inheritance • class extends an existing class !43 www.time2test.co.uk
  44. 44. encapsulation • encapsulation is also referred to as data hiding. !44 www.time2test.co.uk
  45. 45. abstraction • Abstraction refers to the ability to make a class abstract in OOP. An abstract class is one that cannot be instantiated. !45 www.time2test.co.uk
  46. 46. interfaces An interface is a collection of abstract methods. A class implements an interface, thereby inheriting the abstract methods of the interface. !46 www.time2test.co.uk
  47. 47. polymorphism Polymorphism is the ability of an object to take on many forms. The most common use of polymorphism in OOP occurs when a parent class reference is used to refer to a child class object. !47 www.time2test.co.uk
  48. 48. packages • folder structure !48 www.time2test.co.uk
  49. 49. exceptions • Large topic area - lets focus on what we need for web driver and appreciate high level • try • catch • finally • throw !49 www.time2test.co.uk
  50. 50. try - catch • Do something and attempt to catch the exception. • View the java docs to see what type of exceptions can be caught !50 www.time2test.co.uk
  51. 51. enum • An enum type is a special data type that enables for a variable to be a set of predefined constants. • Use them to reduce potential errors in your code ! public enum Day { SUNDAY, MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY } ! !51 www.time2test.co.uk
  52. 52. jUnit
  53. 53. overview • background • integration with Eclipse • notation • assertions • maven • examples !53 www.time2test.co.uk
  54. 54. notation • @Test - Mark your test cases with @Test annotations • @Before and @After - use for “setup” and “tearDown” methods respectively. They run before and after every test case. • @BeforeClass and @AfterClass - Use for class wide “setup” and “tearDown” respectively. They run for one time before and after all test cases. • @Ignore - ignore a test case !54 www.time2test.co.uk
  55. 55. Assertions • assertEquals([String message], expected, actual) - Tests that two values are the same. Note: for arrays the reference is checked not the content of the arrays. • assertTrue([message], boolean condition) - Checks that the boolean condition is true. !55 www.time2test.co.uk
  56. 56. testNG
  57. 57. overview • integration with Eclipse • notation • maven • examples • @DataProvider and @Parameters • differences between jUnit and testNG !57 www.time2test.co.uk
  58. 58. annotations • @BeforeClass - oneTimeSetUp • @BeforeMethod - setUp • @Test - testEmptyCollection • @AfterMethod - tearDown • @BeforeMethod - setUp • @Test - testOneItemCollection • @AfterMethod - tearDown • @AfterClass - oneTimeTearDown !58 www.time2test.co.uk
  59. 59. @Parameters • xml files to grab parameters for tests !59 www.time2test.co.uk
  60. 60. @DataProviders • test data as inputs !60 www.time2test.co.uk
  61. 61. Test Results TestNG by default generates a different type of report for its test execution. This includes an HTML and an XML report output. !61 www.time2test.co.uk
  62. 62. ant
  63. 63. overview • what is ant? • command line usage • benefits • ant and testNG !63 www.time2test.co.uk
  64. 64. Webdriver
  65. 65. overview • more details coming soon !65 www.time2test.co.uk
  66. 66. locating webelements
  67. 67. overview • more details coming soon !67 www.time2test.co.uk
  68. 68. alerts and cookies
  69. 69. overview • more details coming soon !69 www.time2test.co.uk
  70. 70. wait strategies
  71. 71. overview • more details coming soon !71 www.time2test.co.uk
  72. 72. cross browser
  73. 73. overview • more details coming soon !73 www.time2test.co.uk
  74. 74. data driven • Excel spreadsheets or CSV files to seed your tests !74 www.time2test.co.uk
  75. 75. know how
  76. 76. overview • more details coming soon !76 www.time2test.co.uk
  77. 77. Selenium IDE and RC
  78. 78. overview • Selenium IDE! • • javascript functions and random variables • • install and use record and playback Selenium RC! • download and use • cross browser !78 www.time2test.co.uk
  79. 79. Jenkins
  80. 80. overview • more details to follow !80 www.time2test.co.uk
  81. 81. Conclusions
  82. 82. goals and objectives • Review your goals. • Have we met your expectations? • Email us and we will setup a follow up Skype session !82 www.time2test.co.uk
  83. 83. Thank you • From the Time2test Team !83 www.time2test.co.uk

×