SlideShare une entreprise Scribd logo
1  sur  22
Télécharger pour lire hors ligne
The  Page  Object  Pa-ern
A	
  basic	
  DRY	
  abstrac-on	
  pa1ern	
  for	
  Web	
  browser	
  automa-on	
  test	
  
development,	
  maintenance	
  and	
  versioning	
  
Alex	
  Kogon	
  
alex@kogon.com	
  
Basic  Web  Test  Development
• What	
  do	
  we	
  do	
  in	
  Selenium	
  Web	
  Test	
  Development?	
  
	
  
Just	
  like	
  the	
  user,	
  we	
  launch	
  a	
  Web	
  browser,	
  load	
  pages,	
  and	
  read,	
  
write,	
  and	
  click	
  on	
  bu1ons	
  and	
  links.	
  
• How	
  do	
  we	
  interact	
  with	
  the	
  Web	
  browser?	
  
	
  
The	
  Web	
  browser	
  is	
  interface	
  via	
  an	
  Object	
  in	
  your	
  code,	
  which	
  can	
  
be	
  told	
  to	
  load	
  pages,	
  and	
  queried	
  for	
  Element	
  Objects	
  that	
  are	
  
currently	
  on	
  the	
  displayed	
  Web	
  page.	
  These	
  Element	
  Objects	
  may	
  be	
  
read	
  from,	
  wri1en	
  to,	
  or	
  clicked	
  on.	
  
A  First  Basic  Selenium  Script
1.  Load	
  www.google.com	
  
2.  Find	
  the	
  search	
  text	
  field	
  
3.  Enter	
  “Alex	
  Kogon”	
  
4.  Find	
  the	
  search	
  bu1on	
  
5.  Click	
  on	
  it	
  
A  First  Basic  Selenium  Script  (Java)
public	
  class	
  BasicWebTest	
  {	
  
	
  	
  private	
  WebDriver	
  theSeleniumWebDriver;	
  
	
  	
  @Before	
  
	
  	
  public	
  void	
  setUp()	
  throws	
  Exception	
  {	
  
	
  	
  	
  	
  theSeleniumWebDriver	
  =	
  new	
  RemoteWebDriver(new	
  URL("http://localhost:4444/wd/hub"),	
  DesiredCapabilities.firefox());	
  
	
  	
  }	
  
	
  	
  @Test	
  
	
  	
  public	
  void	
  test()	
  {	
  
	
  	
  	
  	
  theSeleniumWebDriver.get("http://www.google.com");	
  
	
  	
  	
  	
  final	
  WebElement	
  myGoogleInputElement	
  =	
  theSeleniumWebDriver.findElement(By.cssSelector("#lst-­‐ib"));	
  	
  	
  	
  
	
  	
  	
  	
  myGoogleInputElement.sendKeys("Alex	
  Kogon");	
  
	
  	
  	
  	
  final	
  WebElement	
  mySearchButtonElement	
  =	
  theSeleniumWebDriver.findElement(By.cssSelector("#tsf	
  >	
  div.tsf-­‐p	
  >	
  div.jsb	
  >	
  center	
  >	
  
input[type="submit"]:nth-­‐child(1)"));	
  
	
  	
  	
  	
  mySearchButtonElement.click();	
  
	
  	
  }	
  
}	
  
	
  
Adding  more  searches
1.  Load	
  www.google.com	
  
2.  Find	
  the	
  search	
  text	
  field	
  
3.  Enter	
  other	
  varia-ons	
  on	
  name	
  (“Alexander	
  Kogon”,	
  “Kogon,	
  Alex”)	
  
4.  Find	
  the	
  search	
  bu1on	
  
5.  Click	
  on	
  it	
  
Another  Search
	
  @Test	
  
	
  	
  public	
  void	
  anotherTest()	
  {	
  
	
  	
  	
  	
  theSeleniumWebDriver.get("http://www.google.com");	
  
	
  	
  	
  	
  final	
  WebElement	
  myGoogleInputElement	
  =	
  
theSeleniumWebDriver.findElement(By.cssSelector("#lst-­‐ib"));	
  	
  	
  	
  
	
  	
  	
  	
  myGoogleInputElement.sendKeys("Kogon,	
  Alex");	
  
	
  	
  	
  	
  final	
  WebElement	
  mySearchButtonElement	
  =	
  
theSeleniumWebDriver.findElement(By.cssSelector("#tsf	
  >	
  
div.tsf-­‐p	
  >	
  div.jsb	
  >	
  center	
  >	
  input[type="submit"]:nth-­‐
child(1)"));	
  
	
  	
  	
  	
  mySearchButtonElement.click();	
  
	
  	
  }	
  
Et  cetera…
	
  	
  @Test	
  
	
  	
  	
  	
  public	
  void	
  yetAnotherTest()	
  {	
  
	
  	
  	
  	
  	
  	
  theSeleniumWebDriver.get("http://www.google.com");	
  
	
  	
  	
  	
  	
  	
  final	
  WebElement	
  myGoogleInputElement	
  =	
  theSeleniumWebDriver.findElement(By.cssSelector("#lst-­‐ib"));	
  	
  	
  	
  
	
  	
  	
  	
  	
  	
  myGoogleInputElement.sendKeys("Alexander	
  Kogon");	
  
	
  	
  	
  	
  	
  	
  final	
  WebElement	
  mySearchButtonElement	
  =	
  theSeleniumWebDriver.findElement(By.cssSelector("#tsf	
  >	
  div.tsf-­‐p	
  >	
  div.jsb	
  >	
  center	
  >	
  
input[type="submit"]:nth-­‐child(1)"));	
  
	
  	
  	
  	
  	
  	
  mySearchButtonElement.click();	
  
	
  	
  	
  	
  }	
  
	
  	
  @Test	
  
	
  	
  	
  	
  public	
  void	
  andSoAnotherTest()	
  {	
  
	
  	
  	
  	
  	
  	
  theSeleniumWebDriver.get("http://www.google.com");	
  
	
  	
  	
  	
  	
  	
  final	
  WebElement	
  myGoogleInputElement	
  =	
  theSeleniumWebDriver.findElement(By.cssSelector("#lst-­‐ib"));	
  	
  	
  	
  
	
  	
  	
  	
  	
  	
  myGoogleInputElement.sendKeys("Kogon,	
  Alexander");	
  
	
  	
  	
  	
  	
  	
  final	
  WebElement	
  mySearchButtonElement	
  =	
  theSeleniumWebDriver.findElement(By.cssSelector("#tsf	
  >	
  div.tsf-­‐p	
  >	
  div.jsb	
  >	
  center	
  >	
  
input[type="submit"]:nth-­‐child(1)"));	
  
	
  	
  	
  	
  	
  	
  mySearchButtonElement.click();	
  
	
  	
  	
  	
  }	
  
Eureka!
Isn’t	
  this	
  great?	
  	
  
	
  
With	
  almost	
  no	
  effort	
  we	
  can	
  write	
  test	
  scripts	
  building	
  new	
  
func-onality	
  from	
  what	
  we’ve	
  already	
  done	
  by	
  copying	
  and	
  pas-ng	
  the	
  
exis-ng	
  work	
  we’ve	
  done	
  and	
  modifying	
  a	
  couple	
  things.	
  
So  what’s  the  problem?
How	
  about	
  if	
  something	
  changes?	
  
	
  
By	
  building	
  a	
  test	
  from	
  an	
  exis-ng	
  site	
  and	
  copying	
  the	
  CSS	
  selectors,	
  it	
  
is	
  easy	
  to	
  build	
  a	
  large	
  body	
  of	
  func-onality	
  tests.	
  However,	
  what	
  
happens	
  if	
  the	
  CSS	
  selectors	
  (or	
  other	
  underlying	
  func-onality)	
  change?	
  
Bri-le  Selectors
Please	
  give	
  us	
  a	
  unique	
  selector!	
  
	
  
When	
  construc-ng	
  selectors,	
  there	
  are	
  a	
  variety	
  of	
  op-ons	
  on	
  how	
  it	
  may	
  be	
  done.	
  The	
  
best	
  selectors	
  reference	
  unique	
  iden-fiers	
  associated	
  with	
  the	
  HTML	
  element,	
  like	
  the	
  
Google	
  Search	
  Text	
  Field	
  in	
  our	
  example	
  code:	
  
theSeleniumWebDriver.findElement(By	
  
	
  	
  	
  	
  	
  	
  	
  	
  .cssSelector("#lst-­‐ib"));	
  
However,	
  quite	
  oben	
  the	
  developers	
  have	
  not	
  inserted	
  unique	
  tags,	
  and	
  we	
  get	
  a	
  selector	
  
similar	
  to	
  what	
  we	
  used	
  for	
  the	
  Google	
  Search	
  Bu1on	
  in	
  our	
  example	
  code:	
  
final	
  WebElement	
  mySearchButtonElement	
  =	
  theSeleniumWebDriver	
  
	
  	
  	
  	
  	
  	
  	
  	
  .findElement(By	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  .cssSelector("#tsf	
  >	
  div.tsf-­‐p	
  >	
  div.jsb	
  >	
  center	
  >	
  
input[type="submit"]:nth-­‐child(1)"));	
  
What  Happens  When  Selectors  Change?
Layout	
  based	
  selectors	
  are	
  a	
  headache…	
  
	
  
Look	
  at	
  the	
  second	
  selector	
  again:	
  
cssSelector("#tsf	
  >	
  div.tsf-­‐p	
  >	
  div.jsb	
  >	
  center	
  >	
  
input[type="submit"]:nth-­‐child(1)"));	
  
With	
  a	
  bit	
  of	
  knowledge	
  of	
  CSS	
  selectors,	
  you	
  can	
  see	
  that	
  this	
  is	
  querying	
  a	
  
subsec-on	
  of	
  the	
  page	
  for	
  all	
  of	
  it’s	
  submit	
  bu1ons,	
  and	
  asking	
  for	
  the	
  first	
  one.	
  
What	
  if	
  the	
  layout	
  of	
  the	
  page	
  changed,	
  or	
  there	
  was	
  another	
  bu1on	
  inserted	
  
before	
  it?	
  Suddenly	
  either	
  no	
  bu1on	
  will	
  be	
  found	
  or	
  the	
  wrong	
  one	
  clicked.	
  
Ideally,	
  the	
  developers	
  can	
  be	
  convinced	
  to	
  insert	
  unique	
  selectors	
  into	
  every	
  
element	
  you	
  need	
  to	
  access,	
  but	
  oben	
  this	
  is	
  not	
  the	
  case.	
  How	
  to	
  handle	
  the	
  
changes?	
  
Brute  Force
Search	
  and	
  Replace	
  
	
  
So	
  let’s	
  assume	
  the	
  guys	
  at	
  Google	
  put	
  in	
  another	
  bu1on	
  before	
  the	
  search	
  bu1on.	
  Our	
  
CSS	
  selector	
  now	
  looks	
  like:	
  
cssSelector("#tsf	
  >	
  div.tsf-­‐p	
  >	
  div.jsb	
  >	
  center	
  >	
  input[type=
"submit"]:nth-­‐child(2)"));	
  
OK,	
  well	
  we’ve	
  got	
  four	
  uses	
  of	
  this	
  selector,	
  but	
  they	
  are	
  all	
  in	
  the	
  same	
  file,	
  so	
  searching	
  
and	
  replacing	
  is	
  not	
  the	
  end	
  of	
  the	
  world.	
  What	
  about	
  if	
  we	
  had	
  hundreds?	
  And	
  they	
  were	
  
in	
  different	
  files?	
  	
  
What	
  if	
  we	
  just	
  had	
  to	
  change	
  it	
  once?	
  While	
  copying	
  and	
  pas-ng	
  code	
  all	
  over	
  is	
  easy	
  and	
  
convenient	
  for	
  reuse,	
  it	
  creates	
  a	
  lot	
  of	
  extra	
  busy	
  work	
  when	
  something	
  needs	
  to	
  be	
  
changed.	
  By	
  crea-ng	
  a	
  “Single	
  Point	
  Of	
  Truth”,	
  or	
  a	
  single	
  way	
  in	
  which	
  this	
  selector	
  is	
  
accessed,	
  we	
  only	
  need	
  to	
  change	
  it	
  once.	
  A	
  bit	
  of	
  extra	
  work	
  up	
  front	
  to	
  save	
  a	
  lot	
  of	
  work	
  
in	
  the	
  future.	
  
Don’t  Repeat  Yourself  (DRY)
Encapsulate	
  code	
  in	
  a	
  single	
  loca-on	
  
	
  
OK,	
  so	
  we’ve	
  copied	
  the	
  same	
  code	
  in	
  four	
  places,	
  and	
  now	
  we	
  need	
  to	
  change	
  it.	
  
To	
  do	
  so	
  most	
  easily,	
  we	
  would	
  like	
  to	
  only	
  have	
  to	
  change	
  it	
  once.	
  What	
  do	
  we	
  do?	
  
Refactor.	
  One	
  of	
  the	
  most	
  powerful	
  innova-ons	
  in	
  modern	
  IDE’s	
  is	
  the	
  ability	
  to	
  
automa-cally	
  have	
  the	
  IDE	
  change	
  code,	
  a.k.a.	
  “refactoring”.	
  Refactoring	
  allows	
  
you	
  to	
  change	
  the	
  architecture	
  of	
  your	
  code	
  on	
  the	
  fly,	
  adop-ng	
  more	
  complicated	
  
structures	
  as	
  demanded,	
  while	
  keeping	
  things	
  as	
  simple	
  as	
  possible	
  at	
  the	
  -me.	
  	
  
There	
  are	
  several	
  possible	
  solu-ons	
  for	
  how	
  to	
  refactor	
  this	
  code	
  to	
  be	
  DRY;	
  we	
  will	
  
work	
  with	
  extrac-ng	
  a	
  common	
  method	
  that	
  is	
  accessed	
  from	
  all	
  the	
  tests.	
  
What  if  the  Selector  is  used  across  mulOple  
script  files?
Share	
  methods	
  within	
  a	
  u-lity	
  class	
  
	
  
So	
  now	
  we’ve	
  created	
  a	
  single	
  method	
  containing	
  the	
  CSS	
  Selector	
  that	
  
can	
  be	
  easily	
  modified	
  to	
  update	
  the	
  Selector	
  when	
  it	
  changes.	
  
However,	
  that	
  method	
  is	
  only	
  in	
  one	
  class.	
  If	
  the	
  selector	
  is	
  used	
  from	
  
mul-ple	
  test	
  script	
  class	
  files,	
  the	
  change	
  must	
  be	
  implemented	
  in	
  each	
  
one.	
  Wouldn’t	
  it	
  be	
  easier	
  to	
  just	
  move	
  the	
  method	
  to	
  another	
  class	
  
where	
  it	
  could	
  be	
  shared	
  by	
  all	
  the	
  different	
  test	
  scripts?	
  
The	
  “Move”	
  refactor	
  is	
  also	
  quite	
  helpful	
  in	
  doing	
  this.	
  
The  Page  Object  Pa-ern
Break	
  your	
  u-lity	
  classes	
  out	
  by	
  Page	
  
	
  
The	
  u-lity	
  class	
  we	
  have	
  just	
  created	
  contains	
  all	
  the	
  logic	
  to	
  access	
  
elements	
  on	
  the	
  Web	
  pages	
  we	
  use	
  in	
  our	
  test.	
  Assuming	
  there	
  are	
  
many	
  Web	
  pages,	
  they	
  are	
  all	
  mixed	
  together	
  in	
  our	
  class.	
  
By	
  breaking	
  out	
  the	
  u-lity	
  class	
  into	
  separate	
  classes,	
  each	
  with	
  the	
  
accessors	
  for	
  a	
  single	
  Web	
  page,	
  we	
  create	
  a	
  be1er	
  abstrac-on	
  where	
  
we	
  can	
  easily	
  share	
  func-onality	
  across	
  our	
  test	
  suite	
  by	
  bringing	
  in	
  
(and	
  extending)	
  exis-ng	
  Page	
  Object	
  code	
  for	
  each	
  page	
  a	
  test	
  uses.	
  
Code	
  
Page  Object  Pa-ern  Architecture
Google	
  
Home	
  
Page	
  
Google	
  
Search	
  
Result	
  
Page	
  
Google	
  
Home	
  
Page	
  
Object	
  
Google	
  
Search	
  
Result	
  
Page	
  
Object	
  
Page  Objects
 Web  Pages
Test	
  1	
  
Test	
  2	
  
Test	
  3	
  
Test  Scripts
Maven  and  Page  Objects
Store	
  each	
  page	
  as	
  a	
  library	
  in	
  Maven	
  
	
  
Now	
  that	
  we’ve	
  broken	
  up	
  our	
  accessors	
  into	
  Page	
  Objects	
  so	
  they	
  can	
  
be	
  easily	
  shared	
  across	
  test	
  scripts,	
  why	
  not	
  put	
  them	
  into	
  a	
  separate	
  
module	
  so	
  that	
  they	
  can	
  be	
  easily	
  shared	
  across	
  test	
  projects	
  as	
  well?	
  
By	
  pugng	
  each	
  Page	
  Object	
  into	
  a	
  unique	
  Maven	
  module,	
  tests	
  can	
  
simply	
  define	
  all	
  the	
  Page	
  Objects	
  they	
  need	
  to	
  reference	
  in	
  their	
  
Maven	
  configura-on	
  (pom.xml)	
  file,	
  and	
  have	
  access	
  to	
  the	
  Page	
  
Objects	
  without	
  needing	
  to	
  copy	
  the	
  Page	
  Objects	
  into	
  mul-ple	
  
projects	
  (another	
  DRY	
  viola-on)	
  or	
  have	
  them	
  all	
  in	
  a	
  single	
  project.	
  
Maven,  Page  Objects,  and  Versioning
Added	
  benefits	
  of	
  using	
  Maven	
  
	
  
OK,	
  now	
  we’ve	
  encapsulated	
  each	
  of	
  our	
  CSS	
  selectors	
  in	
  a	
  single	
  accessor	
  method,	
  stored	
  each	
  of	
  
these	
  in	
  a	
  unique	
  Object	
  represen-ng	
  each	
  Web	
  page	
  used,	
  and	
  created	
  a	
  Maven	
  library	
  for	
  this	
  
Page	
  Object.	
  What	
  next?	
  
When	
  running	
  Web	
  automa-on	
  tes-ng	
  in	
  a	
  large,	
  dynamic,	
  organiza-on,	
  you	
  will	
  find	
  quite	
  oben	
  
that	
  there	
  are	
  mul-ple	
  versions	
  of	
  each	
  Web	
  page	
  that	
  must	
  be	
  tested	
  simultaneously.	
  Reliability	
  
tes-ng	
  on	
  the	
  live	
  site	
  requires	
  the	
  version	
  currently	
  in	
  live	
  is	
  tested;	
  integra-on	
  tes-ng	
  on	
  
imminent	
  releases	
  require	
  the	
  version	
  ready	
  for	
  release;	
  and	
  development	
  tes-ng	
  on	
  new	
  versions	
  
of	
  the	
  Web	
  page	
  (perhaps	
  a	
  pipeline	
  of	
  mul-ple	
  future	
  releases)	
  require	
  the	
  version	
  for	
  each	
  of	
  
those	
  pages.	
  
Luckily	
  Maven	
  already	
  provides	
  us	
  with	
  a	
  solu-on.	
  Maven	
  libraries	
  are	
  easily	
  versioned	
  for	
  
deployment,	
  such	
  that	
  many	
  versions	
  of	
  the	
  library	
  can	
  be	
  available	
  for	
  use	
  by	
  the	
  tests	
  depending	
  
on	
  which	
  version	
  of	
  each	
  page	
  is	
  to	
  be	
  tested.	
  A	
  single	
  test	
  script	
  is	
  s-ll	
  able	
  to	
  be	
  used	
  on	
  the	
  
various	
  versions,	
  as	
  the	
  differences	
  in	
  the	
  implementa-on	
  in	
  each	
  version	
  is	
  abstracted	
  behind	
  the	
  
Page	
  Object.	
  
Code	
  
Page  Object  Pa-ern  Versioning
Google	
  
Home	
  
Page	
  
0.0.1	
  
Google	
  
Home	
  
Page	
  
0.0.2	
  
Google	
  
Home	
  
Page	
  
Object	
  
V	
  0.0.1	
  
Google	
  
Home	
  
Page	
  
Object	
  
V	
  0.0.2	
  
Page  Objects
 Web  Pages
Test	
  1	
  
Test	
  2	
  
Test	
  3	
  
Test  Scripts
ConOnuous  Deployment  and  IntegraOon
The	
  full	
  enchilada	
  
	
  
Now	
  that	
  we’ve	
  got	
  reusable,	
  versioned	
  Page	
  Objects	
  referenced	
  from	
  our	
  Web	
  script	
  code	
  via	
  
Maven,	
  and	
  automated	
  tests	
  which	
  leverage	
  the	
  page	
  objects	
  by	
  version,	
  let’s	
  see	
  how	
  this	
  works	
  in	
  
our	
  Automa-on	
  solu-ons.	
  
A	
  Con-nuous	
  Deployment	
  and	
  Integra-on	
  system	
  can	
  be	
  easily	
  leveraged	
  to	
  provide	
  tes-ng	
  across	
  
all	
  the	
  mul-ple	
  versions	
  in	
  real	
  -me.	
  By	
  allowing	
  the	
  defini-on	
  of	
  the	
  version	
  of	
  each	
  page	
  to	
  be	
  
deployed	
  for	
  each	
  tes-ng	
  to	
  be	
  defined,	
  the	
  correct	
  version	
  of	
  each	
  Page	
  can	
  be	
  deployed	
  into	
  the	
  
Web	
  applica-on	
  servers	
  for	
  the	
  test	
  run,	
  and	
  the	
  correct	
  version	
  of	
  each	
  Page	
  Object	
  corresponding	
  
to	
  that	
  Page	
  version	
  used	
  (by	
  the	
  iden-cal	
  test)	
  by	
  dynamically	
  instruc-ng	
  Maven	
  to	
  use	
  the	
  same	
  
version	
  of	
  the	
  Page	
  Object	
  that	
  was	
  just	
  deployed	
  for	
  tes-ng.	
  
In	
  this	
  way	
  it	
  is	
  very	
  easy	
  to	
  test	
  mul-ple	
  integra-on	
  scenarios	
  in	
  real	
  -me	
  (produc-on,	
  integra-on,	
  
development,	
  etc.),	
  and	
  to	
  easily	
  test	
  any	
  possible	
  integra-on	
  of	
  versions	
  by	
  simply	
  defining	
  the	
  
versions	
  to	
  be	
  used	
  for	
  an	
  Automa-on	
  run.	
  
Try	
  doing	
  that	
  with	
  hard	
  coding.	
  
ConOnuous  IntegraOon  with  Versioning
Jenkins	
  
ConOnuous  
IntegraOon  
Server
Trigger	
  
0.0.1	
  
Build	
  
Checkout	
  
0.0.1	
  
Branch	
  
Git	
  
Version  
Control
Server
Build	
  
0.0.1	
  
Branch	
  
Nexus	
  
Maven  
Deployment  
Server
Tomcat	
  
Web  
ApplicaOon  
Server
Deploy	
  
0.0.1	
  
Branch	
  
Run	
  
0.0.1	
  Test	
  
Maven	
  
Test
Runner
Run	
  With	
  
0.0.1	
  Page	
  
Object	
  
Selenium	
  
Test	
  Run	
  
Firefox	
  
Drive	
  
Browser	
  
Deliver	
  
0.0.1	
  Page	
  
Objects	
  
Deliver	
  
0.0.1	
  
Pages	
  
?

Contenu connexe

Tendances

Testing Rapidly Changing Applications With Self-Testing Object-Oriented Selen...
Testing Rapidly Changing Applications With Self-Testing Object-Oriented Selen...Testing Rapidly Changing Applications With Self-Testing Object-Oriented Selen...
Testing Rapidly Changing Applications With Self-Testing Object-Oriented Selen...
seleniumconf
 
Self-Generating Test Artifacts for Selenium/WebDriver
Self-Generating Test Artifacts for Selenium/WebDriverSelf-Generating Test Artifacts for Selenium/WebDriver
Self-Generating Test Artifacts for Selenium/WebDriver
seleniumconf
 
Selenium withnet
Selenium withnetSelenium withnet
Selenium withnet
Vlad Maniak
 
Test automation expert days
Test automation   expert daysTest automation   expert days
Test automation expert days
Oren Rubin
 
Automated UI Testing Done Right (QMSDNUG)
Automated UI Testing Done Right (QMSDNUG)Automated UI Testing Done Right (QMSDNUG)
Automated UI Testing Done Right (QMSDNUG)
Mehdi Khalili
 
Top100summit 谷歌-scott-improve your automated web application testing
Top100summit  谷歌-scott-improve your automated web application testingTop100summit  谷歌-scott-improve your automated web application testing
Top100summit 谷歌-scott-improve your automated web application testing
drewz lin
 

Tendances (20)

DSL, Page Object and WebDriver – the path to reliable functional tests.pptx
DSL, Page Object and WebDriver – the path to reliable functional tests.pptxDSL, Page Object and WebDriver – the path to reliable functional tests.pptx
DSL, Page Object and WebDriver – the path to reliable functional tests.pptx
 
APIs: A Better Alternative to Page Objects
APIs: A Better Alternative to Page ObjectsAPIs: A Better Alternative to Page Objects
APIs: A Better Alternative to Page Objects
 
Page Object Model and Implementation in Selenium
Page Object Model and Implementation in Selenium  Page Object Model and Implementation in Selenium
Page Object Model and Implementation in Selenium
 
Easy automation.py
Easy automation.pyEasy automation.py
Easy automation.py
 
Testing Rapidly Changing Applications With Self-Testing Object-Oriented Selen...
Testing Rapidly Changing Applications With Self-Testing Object-Oriented Selen...Testing Rapidly Changing Applications With Self-Testing Object-Oriented Selen...
Testing Rapidly Changing Applications With Self-Testing Object-Oriented Selen...
 
Self-Generating Test Artifacts for Selenium/WebDriver
Self-Generating Test Artifacts for Selenium/WebDriverSelf-Generating Test Artifacts for Selenium/WebDriver
Self-Generating Test Artifacts for Selenium/WebDriver
 
Selenium withnet
Selenium withnetSelenium withnet
Selenium withnet
 
Test automation expert days
Test automation   expert daysTest automation   expert days
Test automation expert days
 
Angular UI Testing with Protractor
Angular UI Testing with ProtractorAngular UI Testing with Protractor
Angular UI Testing with Protractor
 
Statistical Element Locator by Oren Rubin - SeleniumConf UK 2016
Statistical Element Locator by Oren Rubin - SeleniumConf UK 2016Statistical Element Locator by Oren Rubin - SeleniumConf UK 2016
Statistical Element Locator by Oren Rubin - SeleniumConf UK 2016
 
Hands on Exploration of Page Objects and Abstraction Layers with Selenium Web...
Hands on Exploration of Page Objects and Abstraction Layers with Selenium Web...Hands on Exploration of Page Objects and Abstraction Layers with Selenium Web...
Hands on Exploration of Page Objects and Abstraction Layers with Selenium Web...
 
Web UI test automation instruments
Web UI test automation instrumentsWeb UI test automation instruments
Web UI test automation instruments
 
Test automation & Seleniun by oren rubin
Test automation & Seleniun by oren rubinTest automation & Seleniun by oren rubin
Test automation & Seleniun by oren rubin
 
Introduction To Web Application Testing
Introduction To Web Application TestingIntroduction To Web Application Testing
Introduction To Web Application Testing
 
Automated UI Testing Done Right (QMSDNUG)
Automated UI Testing Done Right (QMSDNUG)Automated UI Testing Done Right (QMSDNUG)
Automated UI Testing Done Right (QMSDNUG)
 
An Introduction to AngularJS End to End Testing using Protractor
An Introduction to AngularJS End to End Testing using ProtractorAn Introduction to AngularJS End to End Testing using Protractor
An Introduction to AngularJS End to End Testing using Protractor
 
Getting Started with Selenium
Getting Started with SeleniumGetting Started with Selenium
Getting Started with Selenium
 
Gems Of Selenium
Gems Of SeleniumGems Of Selenium
Gems Of Selenium
 
Top100summit 谷歌-scott-improve your automated web application testing
Top100summit  谷歌-scott-improve your automated web application testingTop100summit  谷歌-scott-improve your automated web application testing
Top100summit 谷歌-scott-improve your automated web application testing
 
PhpUnit & web driver
PhpUnit & web driverPhpUnit & web driver
PhpUnit & web driver
 

En vedette

How to Design a Successful Test Automation Strategy
How to Design a Successful Test Automation Strategy How to Design a Successful Test Automation Strategy
How to Design a Successful Test Automation Strategy
Impetus Technologies
 
Introduction to the INTEGRAL FRAMEWORK
Introduction to the INTEGRAL FRAMEWORKIntroduction to the INTEGRAL FRAMEWORK
Introduction to the INTEGRAL FRAMEWORK
Karthik Subramanian
 
Selenium Ide Tutorials
Selenium Ide TutorialsSelenium Ide Tutorials
Selenium Ide Tutorials
gueste1e4db
 

En vedette (20)

Test Automation Framework Designs
Test Automation Framework DesignsTest Automation Framework Designs
Test Automation Framework Designs
 
Automation Testing by Selenium Web Driver
Automation Testing by Selenium Web DriverAutomation Testing by Selenium Web Driver
Automation Testing by Selenium Web Driver
 
Perils of Page-Object Pattern
Perils of Page-Object PatternPerils of Page-Object Pattern
Perils of Page-Object Pattern
 
Using The Page Object Pattern
Using The Page Object PatternUsing The Page Object Pattern
Using The Page Object Pattern
 
Understanding Selenium/RC, Webdriver Architecture and developing the page obj...
Understanding Selenium/RC, Webdriver Architecture and developing the page obj...Understanding Selenium/RC, Webdriver Architecture and developing the page obj...
Understanding Selenium/RC, Webdriver Architecture and developing the page obj...
 
How to Design a Successful Test Automation Strategy
How to Design a Successful Test Automation Strategy How to Design a Successful Test Automation Strategy
How to Design a Successful Test Automation Strategy
 
Test Automation Framework Design | www.idexcel.com
Test Automation Framework Design | www.idexcel.comTest Automation Framework Design | www.idexcel.com
Test Automation Framework Design | www.idexcel.com
 
Selenium Basics Tutorial
Selenium Basics TutorialSelenium Basics Tutorial
Selenium Basics Tutorial
 
Automation Testing using Selenium
Automation Testing using SeleniumAutomation Testing using Selenium
Automation Testing using Selenium
 
Agile breakfast St. Gallen - Mindset. Skillset. Toolset
Agile breakfast St. Gallen - Mindset. Skillset. ToolsetAgile breakfast St. Gallen - Mindset. Skillset. Toolset
Agile breakfast St. Gallen - Mindset. Skillset. Toolset
 
Advanced Selenium Workshop
Advanced Selenium WorkshopAdvanced Selenium Workshop
Advanced Selenium Workshop
 
Introduction to the integral framework
Introduction to the integral frameworkIntroduction to the integral framework
Introduction to the integral framework
 
Introduction to the INTEGRAL FRAMEWORK
Introduction to the INTEGRAL FRAMEWORKIntroduction to the INTEGRAL FRAMEWORK
Introduction to the INTEGRAL FRAMEWORK
 
2 selenium-aakar gupte
2 selenium-aakar gupte2 selenium-aakar gupte
2 selenium-aakar gupte
 
Better Page Object Handling with Loadable Component Pattern - SQA Days 20, Be...
Better Page Object Handling with Loadable Component Pattern - SQA Days 20, Be...Better Page Object Handling with Loadable Component Pattern - SQA Days 20, Be...
Better Page Object Handling with Loadable Component Pattern - SQA Days 20, Be...
 
Selenium Ide Tutorials
Selenium Ide TutorialsSelenium Ide Tutorials
Selenium Ide Tutorials
 
Selenium Webdriver
Selenium WebdriverSelenium Webdriver
Selenium Webdriver
 
Agile Bodensee - Testautomation & Continuous Delivery Workshop
Agile Bodensee - Testautomation & Continuous Delivery WorkshopAgile Bodensee - Testautomation & Continuous Delivery Workshop
Agile Bodensee - Testautomation & Continuous Delivery Workshop
 
Selenium Automation
Selenium AutomationSelenium Automation
Selenium Automation
 
Selenium Automation Framework
Selenium Automation  FrameworkSelenium Automation  Framework
Selenium Automation Framework
 

Similaire à Selenium - The page object pattern

BDD approach with Selenium RC
BDD approach with Selenium RCBDD approach with Selenium RC
BDD approach with Selenium RC
Mykola Kolisnyk
 
2010 07-18.wa.rails tdd-6
2010 07-18.wa.rails tdd-62010 07-18.wa.rails tdd-6
2010 07-18.wa.rails tdd-6
Marakana Inc.
 
jQuery From the Ground Up
jQuery From the Ground UpjQuery From the Ground Up
jQuery From the Ground Up
Kevin Griffin
 
Coldbox developer training – session 4
Coldbox developer training – session 4Coldbox developer training – session 4
Coldbox developer training – session 4
Billie Berzinskas
 
Javascript unit testing, yes we can e big
Javascript unit testing, yes we can   e bigJavascript unit testing, yes we can   e big
Javascript unit testing, yes we can e big
Andy Peterson
 
SearchLove Boston 2013_Will Critchlow_Technical SEO
SearchLove Boston 2013_Will Critchlow_Technical SEOSearchLove Boston 2013_Will Critchlow_Technical SEO
SearchLove Boston 2013_Will Critchlow_Technical SEO
Distilled
 

Similaire à Selenium - The page object pattern (20)

Selenium interview questions and answers
Selenium interview questions and answersSelenium interview questions and answers
Selenium interview questions and answers
 
BDD approach with Selenium RC
BDD approach with Selenium RCBDD approach with Selenium RC
BDD approach with Selenium RC
 
Improving Your Selenium WebDriver Tests - Belgium testing days_2016
Improving Your Selenium WebDriver Tests - Belgium testing days_2016Improving Your Selenium WebDriver Tests - Belgium testing days_2016
Improving Your Selenium WebDriver Tests - Belgium testing days_2016
 
Testing ASP.NET - Progressive.NET
Testing ASP.NET - Progressive.NETTesting ASP.NET - Progressive.NET
Testing ASP.NET - Progressive.NET
 
Selenium Training in Chennai Demo Part-2
Selenium Training in Chennai Demo Part-2 Selenium Training in Chennai Demo Part-2
Selenium Training in Chennai Demo Part-2
 
2010 07-18.wa.rails tdd-6
2010 07-18.wa.rails tdd-62010 07-18.wa.rails tdd-6
2010 07-18.wa.rails tdd-6
 
Efficient Rails Test-Driven Development - Week 6
Efficient Rails Test-Driven Development - Week 6Efficient Rails Test-Driven Development - Week 6
Efficient Rails Test-Driven Development - Week 6
 
2007 Max Presentation - Creating Custom Flex Components
2007 Max Presentation - Creating Custom Flex Components2007 Max Presentation - Creating Custom Flex Components
2007 Max Presentation - Creating Custom Flex Components
 
Automation - web testing with selenium
Automation - web testing with seleniumAutomation - web testing with selenium
Automation - web testing with selenium
 
Latest Selenium Interview Questions And Answers.pdf
Latest Selenium Interview Questions And Answers.pdfLatest Selenium Interview Questions And Answers.pdf
Latest Selenium Interview Questions And Answers.pdf
 
Testing in AngularJS
Testing in AngularJSTesting in AngularJS
Testing in AngularJS
 
jQuery From the Ground Up
jQuery From the Ground UpjQuery From the Ground Up
jQuery From the Ground Up
 
jQuery in the [Aol.] Enterprise
jQuery in the [Aol.] EnterprisejQuery in the [Aol.] Enterprise
jQuery in the [Aol.] Enterprise
 
Beyond the Basics, Debugging with Firebug and Web Inspector
Beyond the Basics, Debugging with Firebug and Web InspectorBeyond the Basics, Debugging with Firebug and Web Inspector
Beyond the Basics, Debugging with Firebug and Web Inspector
 
Coldbox developer training – session 4
Coldbox developer training – session 4Coldbox developer training – session 4
Coldbox developer training – session 4
 
Javascript unit testing, yes we can e big
Javascript unit testing, yes we can   e bigJavascript unit testing, yes we can   e big
Javascript unit testing, yes we can e big
 
SearchLove Boston 2013_Will Critchlow_Technical SEO
SearchLove Boston 2013_Will Critchlow_Technical SEOSearchLove Boston 2013_Will Critchlow_Technical SEO
SearchLove Boston 2013_Will Critchlow_Technical SEO
 
Selenium & PHPUnit made easy with Steward (Berlin, April 2017)
Selenium & PHPUnit made easy with Steward (Berlin, April 2017)Selenium & PHPUnit made easy with Steward (Berlin, April 2017)
Selenium & PHPUnit made easy with Steward (Berlin, April 2017)
 
Selenium
SeleniumSelenium
Selenium
 
Access tips access and sql part 4 building select queries on-the-fly
Access tips  access and sql part 4  building select queries on-the-flyAccess tips  access and sql part 4  building select queries on-the-fly
Access tips access and sql part 4 building select queries on-the-fly
 

Plus de Michael Palotas

Agile bodensee - Agile Testing: Bug prevention vs. bug detection
Agile bodensee - Agile Testing: Bug prevention vs. bug detectionAgile bodensee - Agile Testing: Bug prevention vs. bug detection
Agile bodensee - Agile Testing: Bug prevention vs. bug detection
Michael Palotas
 
Testing in the new world-bug prevention vs. bug detection
Testing in the new world-bug prevention vs. bug detectionTesting in the new world-bug prevention vs. bug detection
Testing in the new world-bug prevention vs. bug detection
Michael Palotas
 
Mobile test automation with Selenium, Selendroid and ios-driver
Mobile test automation with Selenium, Selendroid and ios-driverMobile test automation with Selenium, Selendroid and ios-driver
Mobile test automation with Selenium, Selendroid and ios-driver
Michael Palotas
 
Mobile WebDriver Selendroid
Mobile WebDriver SelendroidMobile WebDriver Selendroid
Mobile WebDriver Selendroid
Michael Palotas
 
Scrum breakfast skillset_toolset_mindset
Scrum breakfast skillset_toolset_mindsetScrum breakfast skillset_toolset_mindset
Scrum breakfast skillset_toolset_mindset
Michael Palotas
 
Mobile Testing and Mobile Automation at eBay
Mobile Testing and Mobile Automation at eBayMobile Testing and Mobile Automation at eBay
Mobile Testing and Mobile Automation at eBay
Michael Palotas
 
ebay @ Hasso Plattner Institut Potsdam
ebay @ Hasso Plattner Institut Potsdamebay @ Hasso Plattner Institut Potsdam
ebay @ Hasso Plattner Institut Potsdam
Michael Palotas
 
How we Test at eBay Europe
How we Test at eBay EuropeHow we Test at eBay Europe
How we Test at eBay Europe
Michael Palotas
 
Swiss Testing Day - Testautomation, 10 (sometimes painful) lessons learned
Swiss Testing Day - Testautomation, 10 (sometimes painful) lessons learnedSwiss Testing Day - Testautomation, 10 (sometimes painful) lessons learned
Swiss Testing Day - Testautomation, 10 (sometimes painful) lessons learned
Michael Palotas
 
Implementing Test Automation in Agile Projects
Implementing Test Automation in Agile ProjectsImplementing Test Automation in Agile Projects
Implementing Test Automation in Agile Projects
Michael Palotas
 

Plus de Michael Palotas (18)

Berlin Selenium Meetup - Galen Framework
Berlin Selenium Meetup -  Galen FrameworkBerlin Selenium Meetup -  Galen Framework
Berlin Selenium Meetup - Galen Framework
 
Berlin Selenium Meetup - A quick introduction to Selenium
Berlin Selenium Meetup - A quick introduction to SeleniumBerlin Selenium Meetup - A quick introduction to Selenium
Berlin Selenium Meetup - A quick introduction to Selenium
 
Zürich selenium meetup mobile and web automation under one umbrella
Zürich selenium meetup mobile and web automation under one umbrellaZürich selenium meetup mobile and web automation under one umbrella
Zürich selenium meetup mobile and web automation under one umbrella
 
Mobile Test Automation using one API and one infrastructure
Mobile Test Automation using one API and one infrastructureMobile Test Automation using one API and one infrastructure
Mobile Test Automation using one API and one infrastructure
 
Agile bodensee - Agile Testing: Bug prevention vs. bug detection
Agile bodensee - Agile Testing: Bug prevention vs. bug detectionAgile bodensee - Agile Testing: Bug prevention vs. bug detection
Agile bodensee - Agile Testing: Bug prevention vs. bug detection
 
Testing in the new world-bug prevention vs. bug detection
Testing in the new world-bug prevention vs. bug detectionTesting in the new world-bug prevention vs. bug detection
Testing in the new world-bug prevention vs. bug detection
 
Mobile test automation with Selenium, Selendroid and ios-driver
Mobile test automation with Selenium, Selendroid and ios-driverMobile test automation with Selenium, Selendroid and ios-driver
Mobile test automation with Selenium, Selendroid and ios-driver
 
German Testing Day Keynote - Testing at ebay - a look at a rather unconvent...
German Testing Day Keynote  - Testing at ebay  - a look at a rather unconvent...German Testing Day Keynote  - Testing at ebay  - a look at a rather unconvent...
German Testing Day Keynote - Testing at ebay - a look at a rather unconvent...
 
Mobile WebDriver Selendroid
Mobile WebDriver SelendroidMobile WebDriver Selendroid
Mobile WebDriver Selendroid
 
Scrum breakfast skillset_toolset_mindset
Scrum breakfast skillset_toolset_mindsetScrum breakfast skillset_toolset_mindset
Scrum breakfast skillset_toolset_mindset
 
EBAY - A LOOK BEHIND THE SCENES
EBAY -  A LOOK BEHIND THE SCENESEBAY -  A LOOK BEHIND THE SCENES
EBAY - A LOOK BEHIND THE SCENES
 
JAVA User Group Bern - Selenium
JAVA User Group Bern  - SeleniumJAVA User Group Bern  - Selenium
JAVA User Group Bern - Selenium
 
Mobile Testing and Mobile Automation at eBay
Mobile Testing and Mobile Automation at eBayMobile Testing and Mobile Automation at eBay
Mobile Testing and Mobile Automation at eBay
 
ebay @ Hasso Plattner Institut Potsdam
ebay @ Hasso Plattner Institut Potsdamebay @ Hasso Plattner Institut Potsdam
ebay @ Hasso Plattner Institut Potsdam
 
How we Test at eBay Europe
How we Test at eBay EuropeHow we Test at eBay Europe
How we Test at eBay Europe
 
Swiss Testing Day - Testautomation, 10 (sometimes painful) lessons learned
Swiss Testing Day - Testautomation, 10 (sometimes painful) lessons learnedSwiss Testing Day - Testautomation, 10 (sometimes painful) lessons learned
Swiss Testing Day - Testautomation, 10 (sometimes painful) lessons learned
 
Implementing Test Automation in Agile Projects
Implementing Test Automation in Agile ProjectsImplementing Test Automation in Agile Projects
Implementing Test Automation in Agile Projects
 
Test Automation and Innovation with Open Source Tools
Test Automation and Innovation with Open Source ToolsTest Automation and Innovation with Open Source Tools
Test Automation and Innovation with Open Source Tools
 

Dernier

Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
chiefasafspells
 
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
masabamasaba
 
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
masabamasaba
 
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
Medical / Health Care (+971588192166) Mifepristone and Misoprostol tablets 200mg
 
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
masabamasaba
 
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
masabamasaba
 
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Medical / Health Care (+971588192166) Mifepristone and Misoprostol tablets 200mg
 

Dernier (20)

WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
 
Announcing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK SoftwareAnnouncing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK Software
 
WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...
WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...
WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...
 
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
 
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park %in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
 
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
 
WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?
 
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
 
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
 
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
 
Architecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastArchitecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the past
 
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
 
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
 
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
 
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open Source
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open SourceWSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open Source
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open Source
 
WSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go PlatformlessWSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go Platformless
 
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
 
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
 

Selenium - The page object pattern

  • 1. The  Page  Object  Pa-ern A  basic  DRY  abstrac-on  pa1ern  for  Web  browser  automa-on  test   development,  maintenance  and  versioning   Alex  Kogon   alex@kogon.com  
  • 2. Basic  Web  Test  Development • What  do  we  do  in  Selenium  Web  Test  Development?     Just  like  the  user,  we  launch  a  Web  browser,  load  pages,  and  read,   write,  and  click  on  bu1ons  and  links.   • How  do  we  interact  with  the  Web  browser?     The  Web  browser  is  interface  via  an  Object  in  your  code,  which  can   be  told  to  load  pages,  and  queried  for  Element  Objects  that  are   currently  on  the  displayed  Web  page.  These  Element  Objects  may  be   read  from,  wri1en  to,  or  clicked  on.  
  • 3. A  First  Basic  Selenium  Script 1.  Load  www.google.com   2.  Find  the  search  text  field   3.  Enter  “Alex  Kogon”   4.  Find  the  search  bu1on   5.  Click  on  it  
  • 4. A  First  Basic  Selenium  Script  (Java) public  class  BasicWebTest  {      private  WebDriver  theSeleniumWebDriver;      @Before      public  void  setUp()  throws  Exception  {          theSeleniumWebDriver  =  new  RemoteWebDriver(new  URL("http://localhost:4444/wd/hub"),  DesiredCapabilities.firefox());      }      @Test      public  void  test()  {          theSeleniumWebDriver.get("http://www.google.com");          final  WebElement  myGoogleInputElement  =  theSeleniumWebDriver.findElement(By.cssSelector("#lst-­‐ib"));                myGoogleInputElement.sendKeys("Alex  Kogon");          final  WebElement  mySearchButtonElement  =  theSeleniumWebDriver.findElement(By.cssSelector("#tsf  >  div.tsf-­‐p  >  div.jsb  >  center  >   input[type="submit"]:nth-­‐child(1)"));          mySearchButtonElement.click();      }   }    
  • 5. Adding  more  searches 1.  Load  www.google.com   2.  Find  the  search  text  field   3.  Enter  other  varia-ons  on  name  (“Alexander  Kogon”,  “Kogon,  Alex”)   4.  Find  the  search  bu1on   5.  Click  on  it  
  • 6. Another  Search  @Test      public  void  anotherTest()  {          theSeleniumWebDriver.get("http://www.google.com");          final  WebElement  myGoogleInputElement  =   theSeleniumWebDriver.findElement(By.cssSelector("#lst-­‐ib"));                myGoogleInputElement.sendKeys("Kogon,  Alex");          final  WebElement  mySearchButtonElement  =   theSeleniumWebDriver.findElement(By.cssSelector("#tsf  >   div.tsf-­‐p  >  div.jsb  >  center  >  input[type="submit"]:nth-­‐ child(1)"));          mySearchButtonElement.click();      }  
  • 7. Et  cetera…    @Test          public  void  yetAnotherTest()  {              theSeleniumWebDriver.get("http://www.google.com");              final  WebElement  myGoogleInputElement  =  theSeleniumWebDriver.findElement(By.cssSelector("#lst-­‐ib"));                    myGoogleInputElement.sendKeys("Alexander  Kogon");              final  WebElement  mySearchButtonElement  =  theSeleniumWebDriver.findElement(By.cssSelector("#tsf  >  div.tsf-­‐p  >  div.jsb  >  center  >   input[type="submit"]:nth-­‐child(1)"));              mySearchButtonElement.click();          }      @Test          public  void  andSoAnotherTest()  {              theSeleniumWebDriver.get("http://www.google.com");              final  WebElement  myGoogleInputElement  =  theSeleniumWebDriver.findElement(By.cssSelector("#lst-­‐ib"));                    myGoogleInputElement.sendKeys("Kogon,  Alexander");              final  WebElement  mySearchButtonElement  =  theSeleniumWebDriver.findElement(By.cssSelector("#tsf  >  div.tsf-­‐p  >  div.jsb  >  center  >   input[type="submit"]:nth-­‐child(1)"));              mySearchButtonElement.click();          }  
  • 8. Eureka! Isn’t  this  great?       With  almost  no  effort  we  can  write  test  scripts  building  new   func-onality  from  what  we’ve  already  done  by  copying  and  pas-ng  the   exis-ng  work  we’ve  done  and  modifying  a  couple  things.  
  • 9. So  what’s  the  problem? How  about  if  something  changes?     By  building  a  test  from  an  exis-ng  site  and  copying  the  CSS  selectors,  it   is  easy  to  build  a  large  body  of  func-onality  tests.  However,  what   happens  if  the  CSS  selectors  (or  other  underlying  func-onality)  change?  
  • 10. Bri-le  Selectors Please  give  us  a  unique  selector!     When  construc-ng  selectors,  there  are  a  variety  of  op-ons  on  how  it  may  be  done.  The   best  selectors  reference  unique  iden-fiers  associated  with  the  HTML  element,  like  the   Google  Search  Text  Field  in  our  example  code:   theSeleniumWebDriver.findElement(By                  .cssSelector("#lst-­‐ib"));   However,  quite  oben  the  developers  have  not  inserted  unique  tags,  and  we  get  a  selector   similar  to  what  we  used  for  the  Google  Search  Bu1on  in  our  example  code:   final  WebElement  mySearchButtonElement  =  theSeleniumWebDriver                  .findElement(By                          .cssSelector("#tsf  >  div.tsf-­‐p  >  div.jsb  >  center  >   input[type="submit"]:nth-­‐child(1)"));  
  • 11. What  Happens  When  Selectors  Change? Layout  based  selectors  are  a  headache…     Look  at  the  second  selector  again:   cssSelector("#tsf  >  div.tsf-­‐p  >  div.jsb  >  center  >   input[type="submit"]:nth-­‐child(1)"));   With  a  bit  of  knowledge  of  CSS  selectors,  you  can  see  that  this  is  querying  a   subsec-on  of  the  page  for  all  of  it’s  submit  bu1ons,  and  asking  for  the  first  one.   What  if  the  layout  of  the  page  changed,  or  there  was  another  bu1on  inserted   before  it?  Suddenly  either  no  bu1on  will  be  found  or  the  wrong  one  clicked.   Ideally,  the  developers  can  be  convinced  to  insert  unique  selectors  into  every   element  you  need  to  access,  but  oben  this  is  not  the  case.  How  to  handle  the   changes?  
  • 12. Brute  Force Search  and  Replace     So  let’s  assume  the  guys  at  Google  put  in  another  bu1on  before  the  search  bu1on.  Our   CSS  selector  now  looks  like:   cssSelector("#tsf  >  div.tsf-­‐p  >  div.jsb  >  center  >  input[type= "submit"]:nth-­‐child(2)"));   OK,  well  we’ve  got  four  uses  of  this  selector,  but  they  are  all  in  the  same  file,  so  searching   and  replacing  is  not  the  end  of  the  world.  What  about  if  we  had  hundreds?  And  they  were   in  different  files?     What  if  we  just  had  to  change  it  once?  While  copying  and  pas-ng  code  all  over  is  easy  and   convenient  for  reuse,  it  creates  a  lot  of  extra  busy  work  when  something  needs  to  be   changed.  By  crea-ng  a  “Single  Point  Of  Truth”,  or  a  single  way  in  which  this  selector  is   accessed,  we  only  need  to  change  it  once.  A  bit  of  extra  work  up  front  to  save  a  lot  of  work   in  the  future.  
  • 13. Don’t  Repeat  Yourself  (DRY) Encapsulate  code  in  a  single  loca-on     OK,  so  we’ve  copied  the  same  code  in  four  places,  and  now  we  need  to  change  it.   To  do  so  most  easily,  we  would  like  to  only  have  to  change  it  once.  What  do  we  do?   Refactor.  One  of  the  most  powerful  innova-ons  in  modern  IDE’s  is  the  ability  to   automa-cally  have  the  IDE  change  code,  a.k.a.  “refactoring”.  Refactoring  allows   you  to  change  the  architecture  of  your  code  on  the  fly,  adop-ng  more  complicated   structures  as  demanded,  while  keeping  things  as  simple  as  possible  at  the  -me.     There  are  several  possible  solu-ons  for  how  to  refactor  this  code  to  be  DRY;  we  will   work  with  extrac-ng  a  common  method  that  is  accessed  from  all  the  tests.  
  • 14. What  if  the  Selector  is  used  across  mulOple   script  files? Share  methods  within  a  u-lity  class     So  now  we’ve  created  a  single  method  containing  the  CSS  Selector  that   can  be  easily  modified  to  update  the  Selector  when  it  changes.   However,  that  method  is  only  in  one  class.  If  the  selector  is  used  from   mul-ple  test  script  class  files,  the  change  must  be  implemented  in  each   one.  Wouldn’t  it  be  easier  to  just  move  the  method  to  another  class   where  it  could  be  shared  by  all  the  different  test  scripts?   The  “Move”  refactor  is  also  quite  helpful  in  doing  this.  
  • 15. The  Page  Object  Pa-ern Break  your  u-lity  classes  out  by  Page     The  u-lity  class  we  have  just  created  contains  all  the  logic  to  access   elements  on  the  Web  pages  we  use  in  our  test.  Assuming  there  are   many  Web  pages,  they  are  all  mixed  together  in  our  class.   By  breaking  out  the  u-lity  class  into  separate  classes,  each  with  the   accessors  for  a  single  Web  page,  we  create  a  be1er  abstrac-on  where   we  can  easily  share  func-onality  across  our  test  suite  by  bringing  in   (and  extending)  exis-ng  Page  Object  code  for  each  page  a  test  uses.  
  • 16. Code   Page  Object  Pa-ern  Architecture Google   Home   Page   Google   Search   Result   Page   Google   Home   Page   Object   Google   Search   Result   Page   Object   Page  Objects Web  Pages Test  1   Test  2   Test  3   Test  Scripts
  • 17. Maven  and  Page  Objects Store  each  page  as  a  library  in  Maven     Now  that  we’ve  broken  up  our  accessors  into  Page  Objects  so  they  can   be  easily  shared  across  test  scripts,  why  not  put  them  into  a  separate   module  so  that  they  can  be  easily  shared  across  test  projects  as  well?   By  pugng  each  Page  Object  into  a  unique  Maven  module,  tests  can   simply  define  all  the  Page  Objects  they  need  to  reference  in  their   Maven  configura-on  (pom.xml)  file,  and  have  access  to  the  Page   Objects  without  needing  to  copy  the  Page  Objects  into  mul-ple   projects  (another  DRY  viola-on)  or  have  them  all  in  a  single  project.  
  • 18. Maven,  Page  Objects,  and  Versioning Added  benefits  of  using  Maven     OK,  now  we’ve  encapsulated  each  of  our  CSS  selectors  in  a  single  accessor  method,  stored  each  of   these  in  a  unique  Object  represen-ng  each  Web  page  used,  and  created  a  Maven  library  for  this   Page  Object.  What  next?   When  running  Web  automa-on  tes-ng  in  a  large,  dynamic,  organiza-on,  you  will  find  quite  oben   that  there  are  mul-ple  versions  of  each  Web  page  that  must  be  tested  simultaneously.  Reliability   tes-ng  on  the  live  site  requires  the  version  currently  in  live  is  tested;  integra-on  tes-ng  on   imminent  releases  require  the  version  ready  for  release;  and  development  tes-ng  on  new  versions   of  the  Web  page  (perhaps  a  pipeline  of  mul-ple  future  releases)  require  the  version  for  each  of   those  pages.   Luckily  Maven  already  provides  us  with  a  solu-on.  Maven  libraries  are  easily  versioned  for   deployment,  such  that  many  versions  of  the  library  can  be  available  for  use  by  the  tests  depending   on  which  version  of  each  page  is  to  be  tested.  A  single  test  script  is  s-ll  able  to  be  used  on  the   various  versions,  as  the  differences  in  the  implementa-on  in  each  version  is  abstracted  behind  the   Page  Object.  
  • 19. Code   Page  Object  Pa-ern  Versioning Google   Home   Page   0.0.1   Google   Home   Page   0.0.2   Google   Home   Page   Object   V  0.0.1   Google   Home   Page   Object   V  0.0.2   Page  Objects Web  Pages Test  1   Test  2   Test  3   Test  Scripts
  • 20. ConOnuous  Deployment  and  IntegraOon The  full  enchilada     Now  that  we’ve  got  reusable,  versioned  Page  Objects  referenced  from  our  Web  script  code  via   Maven,  and  automated  tests  which  leverage  the  page  objects  by  version,  let’s  see  how  this  works  in   our  Automa-on  solu-ons.   A  Con-nuous  Deployment  and  Integra-on  system  can  be  easily  leveraged  to  provide  tes-ng  across   all  the  mul-ple  versions  in  real  -me.  By  allowing  the  defini-on  of  the  version  of  each  page  to  be   deployed  for  each  tes-ng  to  be  defined,  the  correct  version  of  each  Page  can  be  deployed  into  the   Web  applica-on  servers  for  the  test  run,  and  the  correct  version  of  each  Page  Object  corresponding   to  that  Page  version  used  (by  the  iden-cal  test)  by  dynamically  instruc-ng  Maven  to  use  the  same   version  of  the  Page  Object  that  was  just  deployed  for  tes-ng.   In  this  way  it  is  very  easy  to  test  mul-ple  integra-on  scenarios  in  real  -me  (produc-on,  integra-on,   development,  etc.),  and  to  easily  test  any  possible  integra-on  of  versions  by  simply  defining  the   versions  to  be  used  for  an  Automa-on  run.   Try  doing  that  with  hard  coding.  
  • 21. ConOnuous  IntegraOon  with  Versioning Jenkins   ConOnuous   IntegraOon   Server Trigger   0.0.1   Build   Checkout   0.0.1   Branch   Git   Version   Control Server Build   0.0.1   Branch   Nexus   Maven   Deployment   Server Tomcat   Web   ApplicaOon   Server Deploy   0.0.1   Branch   Run   0.0.1  Test   Maven   Test Runner Run  With   0.0.1  Page   Object   Selenium   Test  Run   Firefox   Drive   Browser   Deliver   0.0.1  Page   Objects   Deliver   0.0.1   Pages  
  • 22. ?