simpleExample.rst 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339
  1. Jump-start into worry free production deployments
  2. =================================================
  3. You can try baangt right away and see how it works. It'll take less than 5 minutes.
  4. Prerequisits
  5. ^^^^^^^^^^^^^
  6. * Chrome installed
  7. * Python3 installed
  8. * ``baangt`` installed (either via PIP or from the GIT-Repository at https://gogs.earthsquad.global/athos/baangt)
  9. If you prefer running ``baangt`` inside Docker, use the Dockerfile from https://gogs.earthsquad.global/athos/baangt-Docker.
  10. After downloading the repository, enter ``make build`` and then ``make run`` in the command line.
  11. Once Docker is up, use SVN://localhost:5902 to connect. All features are exactly like you'd install everything on your local machine.
  12. Let's dive right into it
  13. ^^^^^^^^^^^^^^^^^^^^^^^^^
  14. * Start baangt interactive UI by typing `python baangtIA.py`
  15. * In the dropdown "Testrun" chose "SimpleTheInternet.xlsx" and click on "Execute TestRun"
  16. * What's happening here is pretty similar to a real world test case:
  17. * Browser (in this case Firefox) starts up
  18. * Navigate to a certain web page
  19. * click on a link
  20. * navigate back
  21. * click on other link
  22. * click on several elements of the page (e.g. buttons)
  23. * write a report with summary and details about the test case. You'll find the report in the root directory of baangt, unless you stated otherwise.
  24. Extend the Script:
  25. ------------------
  26. For this to work we recommend an XPATH or CSS-plugin for your browser.
  27. Follow these steps to modify the behaviour of the test script:
  28. * Open "SimpleTheInternet.xlsx" from the baangt root directory in Excel or OpenOffice
  29. * In your browser with activated XPATH or CSS-Plugin head over to http://the-internet.com
  30. * Choose one of the links, that you want to play around with and find the XPATH or CSS from your tool.
  31. * Copy and paste this ID in the last line of the XLSX in column C ("Locator").
  32. * Column A ("Activity") should be "CLICK"
  33. * Column B ("LocatorType") will be either XPATH or CSS depending on your tool
  34. * Save the XLSX
  35. * Execute the testrun "SimpleTheInternet.xlsx" in ``baangt`` again.
  36. * Sit back and enjoy your victory!
  37. .. hint::
  38. If you want to be able to watch your browser executing each step, we recommend you set the parameter ``slowExecution`` with value ``True`` in Globals and re-run the test
  39. .. hint ::
  40. If you want the browser window to stay open on errors and/or after execution, you can use parameter ``dontCloseBrowser`` with value ``True``
  41. in global settings and run the test again. The browser will stop on errors or when the test run execution stopped.
  42. A bit further
  43. -------------
  44. Go ahead and try it out with your personal real-world example of a web-page, web-app or SPA, which you would like to have
  45. reproducable regression tests for.
  46. Of course you could basically follow the steps above, but depending on the length and complexity of the execution, you'll
  47. definitely enjoy having more tools in your toolbox:
  48. Recording a test case with Katalon Recorder
  49. -------------------------------------------
  50. Katalon Recorder is a free browser Add-on for Chrome and Firefox. Installation is simple, just google
  51. ``Katalon plugin <your-browser>`` and install the plugin. After installation of the Katalon recorder follow these steps:
  52. * Start the plugin
  53. * Hit the "record"-Button
  54. * Execute the activities you want it to record. Usually following these steps:
  55. * Open a Webpage
  56. * Login (optional)
  57. * Navigate to some sub-page
  58. * Click buttons
  59. * Enter values
  60. * Download documents (optional)
  61. * Stop recording
  62. .. hint::
  63. You might want to execute the test case from within Katalon Recorder to make sure everything was recorded properly.
  64. * Hit the export-Button of the recorder, chose format ``other``
  65. * Click "Export to Clipboard"
  66. * Switch over to ``baangt`` and press the button "Import KatalonRecorder"
  67. * The contents from the clipboard should be imported already and translation to ``baangt`` should be completed. If the clipboard was not inserted automatically, click on the button "Import Clipboard" and please drop a ticket stating your operating system incl. version and which browser you used for recording in Katalon recorder.
  68. * Press "Save" and choose where you want to store the resulting XLSX-File
  69. **That's it. You just created you first regression test case including all parameters for it.**
  70. If you're wondering which parameters these are, and how you can influence them, fear not! Open the Testcase-XLSX from
  71. the last step above, click on the "data"-Tab and start to enter values and lines as you please.
  72. You can always re-run Baangt after saving your Testrun-XLSX and see your progress.
  73. .. hint::
  74. If you want to be able to watch your browser executing each step, set the parameter ``slowExecution`` with value ``True`` in Globals and re-run the test
  75. Tweaking the result
  76. ^^^^^^^^^^^^^^^^^^^
  77. You managed to have a working recording. Congratulations! Let's learn a bit more about the structure of the created XLSX
  78. .. list-table:: Fields in Tab ``TestStepExecution``
  79. :widths: 25 75
  80. :header-rows: 1
  81. * - Column Name
  82. - Description
  83. * - ``Activtity``
  84. - Sets the activity of this TestStep. Activities are described in more details in next chapter
  85. * - ``LocatorType``
  86. - Most of the activities need a locator. We are big fans of XPATH as locatorType, due to speed and ease of use. Sooner
  87. or later you'll anyway end up needing XPATH, so why not use it always when there's no downside? If you prefer
  88. writing CSS-Paths then use value ``CSS`` for the locator. And if you are lucky enough to have unique IDs in your
  89. page simply use ``ID``.
  90. * - ``Locator``
  91. - The locator is the specification on which element ``Activity`` should happen. As in the value fields, you may
  92. use variable replacement here too, in order to replace Locators with values from the data file. For instance the
  93. following would work fine:
  94. ``//*[@id($(CUSTOMERNUMBER))]`` - this would create an XPATH-Statement where $(CUSTOMERNUMBER) is replaced by the
  95. actual value of the current test record.
  96. * - ``Value``
  97. - For instance activity ``SetText`` requires a value (The text to send to a Web-element). You may use fixed values
  98. (which will rarely happen) or values from your test data source, in the simple cases the sheet ``Data`` .
  99. The column names in the sheet ``data`` can be used as variable names (e.g. if you created a column "Quantity" in
  100. your data tab, you can use ``$(Quantity)`` in the field value.
  101. * - ``Comparison`` and ``Value2``
  102. - For some activities (e.g. IF) you not only need the Value-Field but also a comparison operator and a
  103. second field or value to compare to. Values for ``comparison`` are ``eq`` and ``=``. The field ``value2``
  104. follows the same logic as ``value``.
  105. * - ``Timeout``
  106. - Sometimes you might to overwrite the default timeout settings of ``baangt``. Here's your chance. Values in seconds,
  107. decimals are OK (``0.5`` is a valid value, so is ``90``).
  108. * - ``Optional``
  109. - Usually when ``baangt`` tries to execute an activity and can't (after timeout), it will throw an exception,
  110. report in the Logs and stop the current test case. If you set ``optional`` to ``True`` or ``X``, ``baangt``
  111. will continue execution of the test case, even if the activity wasn't possible.
  112. * - ``Release``
  113. - Often you'll face situations, where you want to run a test case in several stages (e.g. DEV, Pre-Quality, Quality,
  114. Migration, Pre-Production, etc.) and the software version on each stage is different. A test case, that works on
  115. Pre-Production will not pass on Dev-System as Dev is already further developed. If you change the test case to work
  116. on Dev-System and you need to test a Hotfix deployment on Pre-Production, what will you do? In other test solutions
  117. you would "simply" copy your test case, have one version for DEV, one for Pre-Production. Do that with hundreds of
  118. different test cases and watch yourself drown in chaos. OR you could use ``baangt`` where this problem is solved.
  119. Software moves through the stages of your system landscape as it evolves. Use this field to conditionally execute
  120. different "branches" of your test cases, depending on the version on the current stage. ``Release`` can be any
  121. string value. You can add "> " "< " and "= " as the first 2 characters to signal to ``baangt`` to only execute
  122. the step when current release is greater than, lower than or exactly equal to the value afterwards, for instance
  123. ::
  124. > 2019.05
  125. will run the line only, if the Version is ``2019.05a`` or ``2019.06``. We are aware, that your version numbers might
  126. follow different nomenclature, so we made it very easy to subclass the corresponding logic.
  127. More details on Activities
  128. --------------------------
  129. .. list-table:: Details of activities
  130. :widths: 25 75
  131. :header-rows: 1
  132. * - Activity
  133. - Description
  134. * - GoToURL
  135. - Navigate to the given URL. Column ``Value`` must provide the URL. You might want to use variables in your URL-String,
  136. for instance your URL might look like this ``https://$(STAGE).earthsquad.global/``. It will be replaced
  137. during runtime of the test data with the value of ``STAGE`` from either Global settings or settings in the
  138. ``testCaseSequence``.
  139. * - click
  140. - Will click on the object specified by the ``locator``.
  141. * - clickIF
  142. - Will click on the object specified by the locator IF the field in testDataDict, that you enter in Column ``value``
  143. has a value. This small and simple extension can save you hours and hours of work in maintenance of testcases.
  144. Imagine you have 10 checkboxes, that in various combinations provide different test results, and you have to test
  145. all possible combinations. Using one column in your datafile for each checkbox and the ``clickif``, you can create
  146. your testCases in minutes instead of hours or days. Imagine 50 checkboxes - with ``baangt`` your effort is still
  147. just minutes.
  148. * - setText
  149. - Write the text given in column ``value`` to the element specified by ``locator``. Only rarely will you have fixed
  150. values. Usually you'll assign columns of the test data using variable replacement (e.g. ``$(POSTCODE)`` to set the
  151. text from column ``POSTCODE`` from the datafile into the destination element.
  152. In some cases we need to write any random value in the field or we need random value like name, string, interger,
  153. date, etc. for some other purpose for that we ``Random`` funtion. You will learn about it further in this document.
  154. * - setTextIF
  155. - Same as SetText, but will only do something in cases where there is a value in the datafile. Similarly to clickIF
  156. this little helper functionality can help you save hours and hours in creation and maintenance of rocksolid and
  157. bulletproof test cases.
  158. * - goBack
  159. - Trigger the "back"-Button of the browser.
  160. * - If/Else/Endif
  161. - The block between IF, ELSE and ENDIF is only executed when the condition evaluated by ``value|comparator|value2`` is
  162. true, for instance:
  163. $(POSTCODE) = 7040
  164. $(YEAR2DATE) > $(YEARTOMONTH)
  165. $(POSTCODE) (no comparison, no Value 2) --> checks for
  166. Additionally you can check for empty/non-existing values by comparing to ``None``.
  167. Another use of the If-Statement is with ``LocatorType`` and ``Locator`` and comparison. This can be used when you
  168. want conditional execution of a larger block of statements depending on an element present or not present.
  169. ``Else`` statement is only executed when if statement is not true.
  170. * - repeat / repeat-done
  171. - See details in <NestedLoops.rst>
  172. * - assert
  173. - Will retrieve value of element specified by ``locator`` and compare with reference value from ``value``.
  174. * - pause
  175. - Will pause for the number of secons in ``value``. Valid numbers are float, e.g. 2, 0.2, 0.1, 25
  176. * - waitForElementPresent
  177. - Will wait (and recheck) to find the element specified by ``locator``. You would use this, when you experience
  178. problems with page load.
  179. * - iban
  180. - Will create a random IBAN account number. ``value 2`` is the destination field of the test case structure. If you
  181. don't provide a field name (not necessarily one that exists in the input file. Can be any field name!) nothing will
  182. happen. If you provide input parameters in column ``value`` (``SWIFT`` and/or ``COUNTRY``) the IBAN will be created for that bank-code
  183. and/or country.
  184. * - pdfcompare
  185. - In a step before you must have downloaded a PDF-File. Before you can compare, you have to provide a reference PDF
  186. to upload. After the upload you'll receive a unique ID for this document. Paste this ID into the ``value`` field.
  187. * - CheckLinks
  188. - Whenever you enter this command, all (if any) links on the current page will be checked and the status of the
  189. link will be reported accordingly. Reporting format is:
  190. Links on <base_url>:
  191. <status>:<Link>
  192. You'll find the output in the Export sheet in the column "CheckedLinks", which will be created automatically.
  193. * - saveto (for Web test cases only)
  194. - Saves the value of the element specified by ``locatorType`` and ``locator`` into the field given in column ``value``.
  195. !!For this case, don't use variable syntax (``$(ColumnName)``) but put the column name only in field Value!!
  196. * - clear
  197. - ``Value`` must have the variable or column name, that should be cleared (without ``$(columnName)``,
  198. just ``columnName``
  199. * - switchwindow
  200. - Switches to a browser window. ``Value`` is the number of the window, that you want to switch to.
  201. * - setanchor
  202. - There are pages, where you'll not find good unique IDs or no nice way to locate elements. Setting an anchor can
  203. help in these cases. An anchor is an element, that can be located by CSS, ID or XPATH. After the anchor is set
  204. all future tries to locate an element will happen within the children of the anchor.
  205. To unset an anchor use setanchor without locator.
  206. setanchor can also improve the location performance, if you're dealing with really large pages.
  207. While an anchor is set, ALL location attempts of elements happen within the anchor's children. If you want
  208. to avoid that, use ```///``` (= 3 slashes instead of 2) to signal the logic to ignore the anchor.
  209. * - TCStopTestCase
  210. - Will stop the current test case from further execution
  211. * - TCStopTestCaseError
  212. - Will stop the current test case and set it's status to NOK
  213. * - address_create
  214. - provide an easy and easily extendable way to generate address data for a test case
  215. The following fields variable are stored in testcaseDataDict:
  216. CountryCode
  217. PostalCode
  218. CityName
  219. StreetName
  220. HouseNumber
  221. AdditionalData1
  222. AdditionalData2
  223. `value` optional
  224. Default field-value: {'HouseNumber': '6', 'AdditionalData1': 'Near MahavirChowk', 'AdditionalData2': 'Opposite St. Marish Church', 'StreetName': 'GoreGaon', 'CityName': 'Ambala', 'PostalCode': '160055', 'CountryCode': 'India'}
  225. These fields can be used as filter criteria in field value.
  226. Example value= `{CountryCode:CY, PostlCode: 7}`.
  227. Resulted field-value :{'HouseNumber': '6', 'AdditionalData1': 'Near MahavirChowk', 'AdditionalData2': 'Opposite St. Marish Church', 'StreetName': 'GoreGaon', 'CityName': 'Ambala', 'PostalCode': '7', 'CountryCode': 'CY'}
  228. `value2` optional
  229. If a prefix was povided in field Value2, the fieldnames will be concatenated with this prefix,
  230. e.g.if value2=`PremiumPayer_`, then the resulting field for CountryCode in testDataDict would become PremiumPayer_CountryCode.
  231. Random
  232. ------
  233. Sometimes we need random values like string, name, integer, float, date, time now in such case we have ``random``
  234. functionality. It is used inside value column of and its structure is
  235. ``$(random{"type":<Type>},"min":<Minimum>,"max"<Maximum>,"format":<Format>)``. Only ``type`` field is compulsory and
  236. every other fields are optional, also each fields are not useful in every type, e.g.- ``name`` type doesn't need any
  237. other optional fields as they are use less for it. You can see fields and types supporting them.
  238. .. list-table:: Fields supporting types
  239. :widths: 25 75
  240. :header-rows: 1
  241. * - Field
  242. - Type
  243. * - type
  244. - This field is compulsory and base of ``random`` funtionality.
  245. string, name, int, float, date, time are the types currently supported
  246. * - min
  247. - string, int, float, date, time are the types supporting this field. Value of min will be with respect to its
  248. type like value for string will be an integer containing minimum number of characters in string and for all other
  249. it will be lower limit, for int it will be an integer & float for float, for date value will be a date e.g. -
  250. "31/01/2020" and for time it would look like "20:30:59"
  251. * - max
  252. - string, int, float, date, time are the types supporting this field. Value of max will be same like in min,
  253. value for string will be an integer containing maximum number of characters in string and for all other it
  254. will be upper limit, for int it will be an integer & float for float, for date value will be a date e.g. -
  255. "01/06/2020" and for time it would look like "13:10:30"
  256. * - format
  257. - date, time are the only types supporting format field. In above date examples date is in %d/%m/%Y format and
  258. time is in %H:%M:%S format. Here "%d" stands for the day, "%m" stands for month, "%Y" stands for year including
  259. century e.g.- 2020, if you want only year you can use "%y" e.g. 20. If you use min and max fields in date, time
  260. then you must input its written format in format field, default will be ""%d/%m/%Y" for date. Now if you want
  261. date with "-" as seperator you can write format as "%d-%m-%Y" so the output would be like "31-01-2020".
  262. `examples`
  263. $(random{"type":"name"})
  264. $(random{"type":"string", "min":10, "max":100})
  265. $(random{"type":"int", "min":10, "max":100})
  266. $(random{"type":"float"})
  267. $(random{"type":"date", "min":"20/1/2020", "max":"30/6/2020", "format":"%d/%m/%Y"})
  268. $(random{"type":"time"})
  269. $(random{"type":"time", "min":"10.30.00", "max":"15.00.00"}, "format": "%H.%M.%S")