SendStatistics.rst 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  1. **************
  2. SendStatistics
  3. **************
  4. While running tests on ``baangt`` we might need to share the report to multiple persons in a team. To do this one might
  5. have to be present in front of screen and wait for completion of the test. But to overcome this issue we have added a
  6. functionality in ``baangt`` to send the reports in various platform automatically, thus you don't need to waste your
  7. time in front of screen just for waiting of completion, our program will take care of that.
  8. Their are 4 different services where we can send test reports. They are:
  9. 1. Email
  10. 2. Ms Teams
  11. 3. Slack
  12. 4. Telegram
  13. 5. Confluence
  14. Lets first discuss things we need to use this services in our program one by one.
  15. **Note :- If you don't need to use any service from the following you just skip that part**
  16. Email
  17. =====
  18. We don't need anything(except recipients email ids).
  19. Ms Teams
  20. ========
  21. We need webhook url of Ms Teams channel where we need to send reports. If you need any help in getting webhook url you can
  22. refer to this link:- https://docs.microsoft.com/en-us/microsoftteams/platform/webhooks-and-connectors/how-to/connectors-using#setting-up-a-custom-incoming-webhook
  23. Slack
  24. =====
  25. We need incoming webhook url for the app which has permission to post message in your group. For further assistance you
  26. can refer to "`Set up Incoming Webhooks`" section of https://slack.com/intl/en-in/help/articles/115005265063-Incoming-webhooks-for-Slack
  27. Telegram
  28. ========
  29. To send message in telegram channel we need channel username and a bot's HTTP API token who has administrator privilage
  30. in your channel.
  31. First, to get username of the channel you can simply go to info section of your channel where you will find invite link
  32. which will look like `t.me/your_channel_username` here your_channel_username is what we need.
  33. Now to get HTTP API token of bot, first we need to create a bot. To create a new bot you need to search for `@botfather` in
  34. telegram. If you are first time user of BotFather then you will see an introduction and a start button in the bottom. If
  35. you don't see start button but seeing a text area in bottom you can just type ``/start`` then to create a new bot you
  36. have to select or type ``/newbot`` after that it will ask a name for your bot. You can name it anything but I for best
  37. practice we will use `ChannelName bot` after that it will ask a username for your bot which must be unique and the
  38. username must end with `bot` word so we can use `ChannelName_bot` after sending this you should get a congratulations
  39. message which means your bot is created. In this congratulation message you will get `HTTP API access token` we will
  40. need this further in our program.
  41. Our next step is to add the bot in our channel as administrator. Please visit this link for further assistance :-
  42. https://stackoverflow.com/a/33497769/8784795
  43. Configuring Baangt
  44. ==================
  45. Once we have all the necessary things we just need to add them in ``mail.ini`` which must be inside ``ini`` folder.
  46. If you have used windows installer to setup ``baangt`` then it must be inside `C:/Users/{username}/baangt` directory,
  47. else it will be in the root directory of baangt. Once you find the ``ini`` folder their must be a main.ini file inside
  48. it. If it is not their you can make one. Just create a new file name `mail` and extension `ini` which will look like
  49. ``mail.ini``. Then you can edit it via any text editor. It should look like.
  50. | [Default]
  51. | sendmailto = <email>
  52. | notificationwithattachment = <True or False>
  53. | mswebhook = <MsTeam channel webhook url>
  54. | slackwebhook = <Slack App webhook url>
  55. | telegrambot = <telegram bot access token>
  56. | telegramchannel = <telegram channel name>
  57. Configurations of mail:- ``sendmailto`` and ``notificationwithattachment`` are the settings for email. ``sendmailto``
  58. can contain single recipients or multiple recipients which would look like.
  59. **sendmailto = example1@xyz.com, example2@xyz.com, example3@xyz.com** inshort they should be comma seperated.
  60. **notificationwithattachment** should be True if you want to send xlsx result file as attachment in the mail else it
  61. should be False.
  62. Configuration of MsTeam:- ``mswebhook`` takes single or multiple(comma seperated as above) webhook url and will send
  63. report in them.
  64. Configuration of Slack:- ``slackwebhook`` takes single or multiple(comma seperated as above) webhook url and will send
  65. report in them.
  66. Configurations of Telegram:- ``telegrambot`` and ``telegramchannel`` are the settings for telegram. ``telegrambot`` will
  67. take single value containing API token of bot. ``telegramchannel`` may contain single or multiple(comma seperated as
  68. above) username of channels. Make sure that all the channels have this bot as administrator.
  69. **Note:- If you don't need to use any of the service out of these four, you can just leave their settings empty**
  70. Override mail.ini
  71. =================
  72. There are some cases when we don't want to send reports either in few or in all services. Now to overcome this what we
  73. can do is that we can add the settings directly in globals file. Our program will always first check for settings in
  74. globals file, if it is not their then it will take settings from ``mail.ini``. Here is an example
  75. | **mail.ini**
  76. | [Default]
  77. | sendmailto = example1@gmail.com
  78. | notificationwithattachment = <True or False>
  79. | mswebhook = <MsTeam channel webhook url>
  80. | slackwebhook = <Slack App webhook url>
  81. | telegrambot = <telegram bot access token>
  82. | telegramchannel = <telegram channel name>
  83. | **globals.json**
  84. | {
  85. | "TC.dontCloseBrowser": "False",
  86. | "TC.NetworkInfo": "False",
  87. | "TC.Browser": "Chrome",
  88. | "TC.BrowserWindowSize": "1024x768",
  89. | "Stage": "Test",
  90. | "SendMailTo": "example2@gmail.com, example3@gmail.com",
  91. | "NotificationWithAttachment": "False",
  92. | "MsWebHook": "",
  93. | "SlackWebHook": "",
  94. | }
  95. Now as we can see the we have override Mail, Ms Teams & Slack settings. So now our program will take mails from globals
  96. and as the ``NotificationWithAttachment`` parameter is False it won't attach the xlsx file. ``MsWebHook`` & ``SlackWebHook``
  97. are empty so no report will be sent on those platforms. Here we haven't declared any setting for **Telegram** so the
  98. program will now look for those settings in ``mail.ini`` and send the report as per that settings.
  99. Confluence
  100. ==========
  101. We also have functionality to update report in confluence. Reports are updated as page. Along with it we can also attach
  102. original report(.xlsx) file in main page. Main page can consist link to original file, data from "Summary" tab & data
  103. from "Output" tab. Their might also be cases when "Output" tab has too many datas, so we have solution for that too. We
  104. have given you an option to create subpages of data from "Output" tab. You can use this functionality with the help of
  105. global files. Lets see the keywords needed for global file in order to update the report in confluence.
  106. | **globals.json**
  107. | {
  108. | "Confluence-Base-Url" : "",
  109. | "Confluence-Space" : "",
  110. | "Confluence-Username" : "",
  111. | "Confluence-Password" : "",
  112. | "Confluence-Rootpage" : "",
  113. | "Confluence-Pagetitle" : "",
  114. | "Confluence-Remove_Headers" : "",
  115. | "Confluence-Uploadoriginalfile" : "",
  116. | "Confluence-Createsubpagesforeachxxentries" : 0
  117. | }
  118. **Confluence-Base-Url**
  119. ``Confluence-Base-Url`` contains the url for your confluence.
  120. **Confluence-Space**
  121. ``Confluence-Space`` contains the name of space where page
  122. is to be created.
  123. **Confluence-Username**
  124. ``Confluence-Username`` contains your username.
  125. **Confluence-Password**
  126. ``Confluence-Password`` contains your password.
  127. **Confluence-Rootpage**
  128. ``Confluence-Rootpage`` contains parent page id, this option is optional and in most of the case is not usable, you must
  129. use this option if you want to create the report page as a sub-page to another main page.
  130. **Confluence-Pagetitle**
  131. ``Confluence-Pagetitle`` title for the report page.
  132. **Confluence-Remove_Headers**
  133. ``Confluence-Remove_Headers`` contains headers from "Output" tab which are not to be considered
  134. while generating report page. Multiple headers should be sperated by comma, e.g. - "header1, header2, header3".
  135. **Confluence-Uploadoriginalfile**
  136. ``Confluence-Uploadoriginalfile`` value must be true if you want to upload original xlsx file in main report page.
  137. **Confluence-Createsubpagesforeachxxentries**
  138. ``Confluence-Createsubpagesforeachxxentries`` contain integer, when we want to create sub-pages for "Output" tab data
  139. we should input the number of rows present in a subpage, multiple sub-pages are created with the number of rows which
  140. are defined here. e.g. - "Confluence-Createsubpagesforeachxxentries" : 100, here we have given input of maximum 100 data
  141. in a sub-page and suppose if total number of data is 288, then their will be 3 pages containing 1-100, 101-200, 201-288
  142. data.