Selenium Training

1,145 views

Published on

Pragmatic Test Labs provide online training for software testers who wants to learn

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

No Downloads
Views
Total views
1,145
On SlideShare
0
From Embeds
0
Number of Embeds
7
Actions
Shares
0
Downloads
21
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

Selenium Training

  1. 1. WEB APPLICATIONS TEST AUTOMATION USING SELENIUMJANESH KODIKARA- PRAGMATIC TEST LABS 11 November 2012 1
  2. 2. AGENDA  Selenium IDE  Test Cases and Test Suites  Selenium Commands  Regular Expression  Ajax Applications  User Extensions and Flow Controls  Cross Browser Testing  Location Strategies  Alerts, Popups and Multiple WindowsJANESH KODIKARA- PRAGMATIC TEST LABS 11 November 2012 2
  3. 3. SELENIUM IDE  Installation  Selenium IDE Features  Understand Timeout  Limitations of Selenium IDEJANESH KODIKARA- PRAGMATIC TEST LABS 11 November 2012 3
  4. 4. JANESH KODIKARA- PRAGMATIC TEST LABS 11 November 2012 ‹#›
  5. 5. HELLO SELENIUMJANESH KODIKARA- PRAGMATIC TEST LABS 11 November 2012 5
  6. 6. FREQUENTLY USED COMMANDS  open  click / clickAndWait  verifyTitle / assertTitle  verifyTextPresent  verifyElementPresent  verifyText  verifyTable  waitForPageToLoad  waitForElementPresentJANESH KODIKARA- PRAGMATIC TEST LABS 11 November 2012 6
  7. 7. SELENIUM IDE : LOG PANE  Useful for Debugging  Automatically Selected When Tests are ExecutedJANESH KODIKARA- PRAGMATIC TEST LABS 11 November 2012 7
  8. 8. SELENIUM IDE : REFERENCE PANE  Display Reference of Current Command  Default PaneJANESH KODIKARA- PRAGMATIC TEST LABS 11 November 2012 8
  9. 9. SELENIUM IDE : MENU BAR  Speed Control  Run All Tests  Run Currently Selected Test  Pause/Resume  Step  Apply Roll-up Rules  RecordingJANESH KODIKARA- PRAGMATIC TEST LABS 11 November 2012 9
  10. 10. SELENIUM IDE : TEST CASE PANE  Use for Editing Commands  Read Reference Documentation Before Giving Parameters (e.g. Store Command)JANESH KODIKARA- PRAGMATIC TEST LABS 11 November 2012 10
  11. 11. SELENIUM IDE : TEST CASE PANE  Context Menu  Stop in the Middle  Start from the Middle  Run Single CommandJANESH KODIKARA- PRAGMATIC TEST LABS 11 November 2012 11
  12. 12. TEST CASES AND TEST SUITES  Create Test Cases  Create Test Suites  Naming Conventions  Test Project Packaging and Best Practices  Modifying Test Cases and Test Suites  User of Variables in Test Cases  Creating and Using Random VariablesJANESH KODIKARA- PRAGMATIC TEST LABS 11 November 2012 12
  13. 13. EDITING  Adding New Commands  Inset Comments  Editing Test Cases  Editing Test Suites  Table View, Source ViewJANESH KODIKARA- PRAGMATIC TEST LABS 11 November 2012 13
  14. 14. VARIABLESJANESH KODIKARA- PRAGMATIC TEST LABS 11 November 2012 14
  15. 15. VERIFY PAGE ELEMENTS  Element Present Somewhere in the Page  Specific Text Present in Somewhere in the Page  Specific Text Present at Specific LocationJANESH KODIKARA- PRAGMATIC TEST LABS 11 November 2012 15
  16. 16. ASSERT OR VERIFY?  When to use assert commands  When to use verify commandsJANESH KODIKARA- PRAGMATIC TEST LABS 11 November 2012 16
  17. 17. FEW USEFUL STORE COMMANDS  store  storeElementPresent  storeHtmlSource  storeEditable  storeTitle  storeSelectedLabel  storeTableJANESH KODIKARA- PRAGMATIC TEST LABS 11 November 2012 17
  18. 18. STORE COMMAND : EXAMPLEJANESH KODIKARA- PRAGMATIC TEST LABS 11 November 2012 18
  19. 19. USE OF VARIABLES IN JAVASCRIPTS storeEval command storedVars[counter]=parseInt(storedVars[counter])+1 Javascript{ ${variableName} + ‘Some Text’ } Case SensitivityJANESH KODIKARA- PRAGMATIC TEST LABS 11 November 2012 19
  20. 20. MATCHING TEXT PATTERNS Globbing Patterns Regular Expression Patterns Exact PatternJANESH KODIKARA- PRAGMATIC TEST LABS 11 November 2012 20
  21. 21. REGULAR EXPRESSIONSJANESH KODIKARA- PRAGMATIC TEST LABS 11 November 2012 21
  22. 22. REGULAR EXPRESSION <tr> <td>verifyTitle</td> <td>regexp:.*Simplicity into Software Testing</td> <td></td> </tr> <tr> <td>verifyTitle</td> <td>regexpi:.*simplicity into software testing</td> <td></td> </tr>JANESH KODIKARA- PRAGMATIC TEST LABS 11 November 2012 22
  23. 23. LOGS  Setting Log LevelsJANESH KODIKARA- PRAGMATIC TEST LABS 11 November 2012 23
  24. 24. SELENIUM COMMANDS  Selense  Actions  Assessors  AssertionsJANESH KODIKARA- PRAGMATIC TEST LABS 11 November 2012 24
  25. 25. ACTIONS  Commands that Manipulate the State  Click this link, Select that Option  Test Stops if Actions Fail or has an Error  Commands with ‘AndWait’ Suffix  Hands-onJANESH KODIKARA- PRAGMATIC TEST LABS 11 November 2012 25
  26. 26. ACCESSORS  Examine State and Store the Value in Variable  Store Commands  Test Stops if an Accessor has an Error  Hands-onJANESH KODIKARA- PRAGMATIC TEST LABS 11 November 2012 26
  27. 27. ASSERTIONS  Like Accessors  Verify and Confirm the State  Asserts, Verify and WaitFor  When Assert Fails Test is Aborted  When Verify Fails Test Continue, Failure is LoggedJANESH KODIKARA- PRAGMATIC TEST LABS 11 November 2012 27
  28. 28. TESTING AJAX  Understanding Ajax  WaitFor Commands  Hands-onJANESH KODIKARA- PRAGMATIC TEST LABS 11 November 2012 28
  29. 29. LOCATION STRATEGIES  Locating Elements in a Web Application  Format LocatorType=Location  Supported Strategies  We Can Define Our Own StrategiesJANESH KODIKARA- PRAGMATIC TEST LABS 11 November 2012 29
  30. 30. LOCATION STRATEGIES : IDENTIFIER  Default Strategy  identifier=id  Select the element with the specified @id attribute  If no match is found, select the first element whose @name attribute is idJANESH KODIKARA- PRAGMATIC TEST LABS 11 November 2012 30
  31. 31. LOCATION STRATEGIES : ID  id=id  Select the element with the specified @id attribute  Hands-onJANESH KODIKARA- PRAGMATIC TEST LABS 11 November 2012 31
  32. 32. LOCATION STRATEGIES : NAME  name=name  Select the first element with the specified @name attribute  Optionally be Followed by One or More Element-filters  Default Filter is Value  name=company value=AllionJANESH KODIKARA- PRAGMATIC TEST LABS 11 November 2012 32
  33. 33. LOCATION STRATEGIES : DOM  dom=javascriptExpression  Find an element by evaluating the specified string  Traverse HTML Document Object Model using JavaScript  dom=document.forms[myForm].myDropdown  dom=document.images[56]JANESH KODIKARA- PRAGMATIC TEST LABS 11 November 2012 33
  34. 34. LOCATION STRATEGIES : XPATH  xpath=xpathExpression  Locate an element using an XPath expression.  xpath=//img[@alt=The image alt text]  xpath=//a[contains(@href,#id1)]  xpath=//input[@name=name2 and @value=yes]JANESH KODIKARA- PRAGMATIC TEST LABS 11 November 2012 34
  35. 35. LOCATION STRATEGIES : LINK  link=textPattern  Select the link (anchor) element which contains text matching the specified patternJANESH KODIKARA- PRAGMATIC TEST LABS 11 November 2012 35
  36. 36. LOCATION STRATEGIES : CSS  css=cssSelectorSyntax  Select the element using css selectors  css=input[name="username"]  css=input.required[type="text"]  css=#loginForm input:nth-child(2)JANESH KODIKARA- PRAGMATIC TEST LABS 11 November 2012 36
  37. 37. USER EXTENSIONS  Helps to Add Additional Functionality  Install a User Extension  Flow Controls  Selenium and PageBot Object PrototypeJANESH KODIKARA- PRAGMATIC TEST LABS 11 November 2012 37
  38. 38. USER EXTENSIONS  Writing Your Own Action  Wiring Your Own Assertion  Writing Your Own Location StrategyJANESH KODIKARA- PRAGMATIC TEST LABS 11 November 2012 38
  39. 39. CROSS BROWSER TESTING  Installing RC  Starting RC Server  Running TestsJANESH KODIKARA- PRAGMATIC TEST LABS 11 November 2012 39
  40. 40. CROSS BROWSER TESTING : RC Java -jar selenium-server.jar -userExtensions user-extensions.js -htmlSuite "*firefox“ "http://www.google.com" "c:absolutepathtomyHTMLSuite.html“ "c:absolutepathtomyresults.html"JANESH KODIKARA- PRAGMATIC TEST LABS 11 November 2012 40
  41. 41. ALERTSassertAlert(Pattern) : Throws error if pattern does not matchassertAlertPresent : Useful when we don’t know the messageassertAlertNotPresent : Throws error if alert is presentstoreAlert(variable) : Stores the message to a variable JANESH KODIKARA- PRAGMATIC TEST LABS 11 November 2012 41
  42. 42. CONFIRMATIONSassertConfirmation(Pattern) : Simulates clicking OKchooseCancelOnNextConfirmationchooseOkOnNextConfirmation JANESH KODIKARA- PRAGMATIC TEST LABS 11 November 2012 42
  43. 43. JAVASCRIPTS AND SELENSE PARAMETERSScript Parameters JANESH KODIKARA- PRAGMATIC TEST LABS 11 November 2012 43
  44. 44. JAVASCRIPTS AND SELENSE PARAMETERSNon-Script Parameters JANESH KODIKARA- PRAGMATIC TEST LABS 11 November 2012 44
  45. 45. DEBUGGINGJANESH KODIKARA- PRAGMATIC TEST LABS 11 November 2012 45
  46. 46. ECHO – PRINT COMMANDJANESH KODIKARA- PRAGMATIC TEST LABS 11 November 2012 46
  47. 47. JANESH KODIKARA- PRAGMATIC TEST LABS 11 November 2012 47
  48. 48. SELENIUM PLUGINSFile LoggingHighlight ElementsLog Search BarPage CoveragePower DebuggerScreenshot on FailSelenium ExpertStored Variables ViewerTest ResultsTest Suite Batch Converter JANESH KODIKARA- PRAGMATIC TEST LABS 11 November 2012 48
  49. 49. JANESH KODIKARA- PRAGMATIC TEST LABS 11 November 2012 49

×