Diese Präsentation wurde erfolgreich gemeldet.
Die SlideShare-Präsentation wird heruntergeladen. ×

QTP Descriptive Programming

Weitere Verwandte Inhalte

Ähnliche Bücher

Kostenlos mit einer 30-tägigen Testversion von Scribd

Alle anzeigen

Ähnliche Hörbücher

Kostenlos mit einer 30-tägigen Testversion von Scribd

Alle anzeigen

QTP Descriptive Programming

  1. 1. <ul><li>DP 101 in 60 simple slides </li></ul><ul><li>www.AdvancedQTP.com </li></ul>
  2. 2. <ul><li>What is DP? </li></ul><ul><li>DP stands for </li></ul><ul><li>Descriptive Programming </li></ul>
  3. 3. <ul><li>But what IS DP? </li></ul><ul><li>I t’s a cool way to work without QTP’s Object-Repository (OR) </li></ul>
  4. 4. <ul><li>Why would I want to do that? </li></ul>
  5. 5. <ul><li>Many reasons </li></ul>
  6. 6. <ul><li>You have to </li></ul><ul><li>Functions & Recovery scenarios work with different actions </li></ul><ul><li>Different actions = Different ORs </li></ul>
  7. 7. Do I know you? Can’t be sure…
  8. 8. <ul><li>You have to </li></ul><ul><li>Can’t record certain objects </li></ul><ul><li>Auto-hide panels </li></ul><ul><li>Objects with changing hierarchies </li></ul><ul><li>Nested inner-objects, Sub menus </li></ul>
  9. 9. Hold still, damnit! Even when you think you got it, all the properties turn out null
  10. 10. <ul><li>Simplicity </li></ul><ul><li>Why kill a fly with an atom bomb? </li></ul><ul><li>No need to use the OR for every one-time click button in the application </li></ul>
  11. 11. <ul><li>And, </li></ul><ul><li>You can do VERY cool things with DP </li></ul>
  12. 12. <ul><li>OK, bring it on </li></ul>
  13. 13. <ul><li>First, we need to better understand the Object Repository </li></ul><ul><li>What the OR is </li></ul><ul><li>How does the OR work </li></ul>
  14. 14. <ul><li>I thought DP is all about NOT using the OR… </li></ul>
  15. 15. <ul><li>Well, yes, but under the hood, DP & the OR work the same way </li></ul><ul><li>To understand the OR, is to understand DP </li></ul>
  16. 16. <ul><li>What is the OR? </li></ul>
  17. 17. <ul><li>A mysterious beast that records objects, in order to use them later </li></ul>
  18. 18. <ul><li>What is to record an object? </li></ul><ul><li>Write down how to identify it </li></ul>
  19. 19. <ul><li>Who are you? </li></ul>= How can I identify you?
  20. 20. <ul><li>Identification is done with </li></ul><ul><li>properties and values </li></ul>
  21. 21. <ul><li>Who are you? </li></ul>= Your height = 400 Your title = “NotePad” You are visible (=True)
  22. 22. <ul><li>So, What IS the OR? </li></ul><ul><li>Collections of properties & corresponding values </li></ul><ul><li>Each collection represents an object </li></ul><ul><li>No mysterious beast here </li></ul>
  23. 23. <ul><li>OK, So what IS DP? </li></ul><ul><li>DP is a way for specifying the properties & values without using the OR interface </li></ul><ul><li>No mysterious beast here, either </li></ul>
  24. 24. <ul><li>OK, I get it, there’s nothing more than properties and values </li></ul><ul><li>Can we get on with it? </li></ul>
  25. 25. <ul><li>How do I actually use DP? </li></ul><ul><li>There are two ways </li></ul>
  26. 26. <ul><li>1 </li></ul><ul><li>Throw the properties and values straight into a command </li></ul>
  27. 27. It’s the good old syntax you know, except the string between the () is not the OR name. It’s the property:=value identification string
  28. 28. <ul><li>That’s kinda restrictive </li></ul><ul><li>What if I want to use multiple identification properties? </li></ul>
  29. 29. <ul><li>No problem: </li></ul><ul><li>VBWindow(“height:=400”, “title:=New Document”).Maximize </li></ul><ul><li>You can use as many properties as you like </li></ul>
  30. 30. <ul><li>All fine and well, but what if I want to use regular expressions? </li></ul>
  31. 31. <ul><li>No problem: </li></ul><ul><li>VBWindow(“title:=.*Document.*”).Maximize </li></ul><ul><li>ID strings are automatically interpreted as regular expressions </li></ul>
  32. 32. <ul><li>2 </li></ul><ul><li>Throw the properties & values into a description object, and throw IT into the command </li></ul>
  33. 33. Here also, all the values are interpreted as regular expressions. To turn it off, use oDesc(“Property1”).RegularExpression = False
  34. 34. <ul><li>Method 1 is faster, best used for one or two commands, tops </li></ul>
  35. 35. <ul><li>When you want to execute multiple commands on an object, method 2 is a better choice by far </li></ul><ul><li>(allows one-time definitions, multiple uses) </li></ul>
  36. 36. <ul><li>You can use DP with OR </li></ul><ul><li>VBWindow(“OR”).VBButton(“text:=OK”).Click </li></ul><ul><li>Or (when oDesc is a description object): </li></ul><ul><li>VBWindow(“OR”).VBButton(oDesc).Click </li></ul>
  37. 37. <ul><li>But , you can only start from OR, and move to DP </li></ul><ul><li>So this will not work: </li></ul><ul><li>VBWindow(“title:=notgood”).VBButton(“clickme”).Click </li></ul>
  38. 38. <ul><li>And that’s about it </li></ul><ul><li>You can use each of the methods (or combine them), and you’ll be able to use objects that are not in the OR </li></ul>
  39. 39. <ul><li>You said I could do really cool stuff with DP! </li></ul>
  40. 40. <ul><li>Right you are </li></ul><ul><li>We’ll cover some of the more popular tricks and tips </li></ul><ul><li>These examples are only the tip of the iceberg. Play with them and see the true power of DP </li></ul>
  41. 41. <ul><li>The power of the string </li></ul><ul><li>DP is nothing more than simple strings </li></ul><ul><li>We can do such interesting things with strings… </li></ul>
  42. 42. <ul><li>The power of the string </li></ul><ul><li>Say we got an app with 4 checkboxes, check0, …, check4 </li></ul><ul><li>We can set all of them with a nice simple loop: </li></ul>
  43. 43. <ul><li>The power of the string </li></ul><ul><li>Very complex identification tasks can be done via strings manipulation </li></ul><ul><li>Try different variations for yourself </li></ul>
  44. 44. <ul><li>Solving double objects </li></ul><ul><li>When QTP finds two object which match the same description, it freezes </li></ul><ul><li>This kinda sucks </li></ul>
  45. 45. ?
  46. 46. <ul><li>DP has a magic property: “index”, which allows us to tell the double objects apart </li></ul><ul><li>Index is a zero-based counter </li></ul>
  47. 47. All is well
  48. 48. <ul><li>Getting objects collections </li></ul><ul><li>This feature is so cool, deserves a title on its own </li></ul>
  49. 49. <ul><li>THE coolest thing you can do with DP, is to get a collection of all the objects that math an identification </li></ul>
  50. 50. I don’t know who you are, or how many are you, but I want to mark all of you! Regular DP won’t help - Don’t know how to identify each checkbox
  51. 51. <ul><li>Object collections to the rescue! </li></ul><ul><li>Step 1: define a description object </li></ul>
  52. 52. <ul><li>Object collections to the rescue! </li></ul><ul><li>Step 2: get all matching objects </li></ul>
  53. 53. <ul><li>Object collections to the rescue! </li></ul><ul><li>Step 3: Use the collection </li></ul><ul><li>oChildren now holds a collection of all the checkboxes </li></ul><ul><li>So the first checkbox is accessed by: oChildren(0) </li></ul>
  54. 54. <ul><li>What can we do with it? </li></ul><ul><li>Anything we want </li></ul>
  55. 55. <ul><li>Example for common uses </li></ul><ul><li>Mark all Checkboxes </li></ul><ul><li>Mark all checkboxes with a certain property (even RO) </li></ul>
  56. 56. <ul><li>The possibilities are endless </li></ul><ul><li>Randomly input fields </li></ul><ul><li>Input only mandatory fields </li></ul><ul><li>Zero maintenance (new fields are added automatically, blind to UI changes) </li></ul><ul><li>Select object which match complex identification criteria (write custom if filters) </li></ul><ul><li>The list goes on and on… </li></ul>
  57. 57. <ul><li>OK, this is indeed cool, but it only gets us the inner controls of a given window. </li></ul><ul><li>Can we also get the application’s top level windows? </li></ul>
  58. 58. <ul><li>Sure </li></ul>
  59. 59. <ul><li>So, With DP we can work with no OR </li></ul><ul><li>Sometimes we have to use it </li></ul><ul><li>Other times it’s just more fun and useful </li></ul><ul><li>DP also throws in a lot of extras that make it an inseparable part of good QTP automation </li></ul><ul><li>Taste it, Experience it, Learn it, Use it, Love it </li></ul><ul><li>It’s worth your while </li></ul>
  60. 60. <ul><li>And that was DP in 60 slides </li></ul>

×