Developer.html 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348
  1. <!DOCTYPE html>
  2. <!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]-->
  3. <!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]-->
  4. <head>
  5. <meta charset="utf-8">
  6. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  7. <title>Developer guidelines for custom enhancements &mdash; baangt 1.1.1 documentation</title>
  8. <script type="text/javascript" src="_static/js/modernizr.min.js"></script>
  9. <script type="text/javascript" id="documentation_options" data-url_root="./" src="_static/documentation_options.js"></script>
  10. <script type="text/javascript" src="_static/jquery.js"></script>
  11. <script type="text/javascript" src="_static/underscore.js"></script>
  12. <script type="text/javascript" src="_static/doctools.js"></script>
  13. <script type="text/javascript" src="_static/language_data.js"></script>
  14. <script type="text/javascript" src="_static/js/theme.js"></script>
  15. <link rel="stylesheet" href="_static/css/theme.css" type="text/css" />
  16. <link rel="stylesheet" href="_static/pygments.css" type="text/css" />
  17. <link rel="stylesheet" href="_static/theme_overrides.css" type="text/css" />
  18. <link rel="index" title="Index" href="genindex.html" />
  19. <link rel="search" title="Search" href="search.html" />
  20. <link rel="next" title="What is a baangt-plugin" href="baangt-Plugin.html" />
  21. <link rel="prev" title="DataGenerator" href="Datagenerator.html" />
  22. </head>
  23. <body class="wy-body-for-nav">
  24. <div class="wy-grid-for-nav">
  25. <nav data-toggle="wy-nav-shift" class="wy-nav-side">
  26. <div class="wy-side-scroll">
  27. <div class="wy-side-nav-search" >
  28. <a href="index.html" class="icon icon-home"> baangt
  29. </a>
  30. <div role="search">
  31. <form id="rtd-search-form" class="wy-form" action="search.html" method="get">
  32. <input type="text" name="q" placeholder="Search docs" />
  33. <input type="hidden" name="check_keywords" value="yes" />
  34. <input type="hidden" name="area" value="default" />
  35. </form>
  36. </div>
  37. </div>
  38. <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
  39. <p class="caption"><span class="caption-text">Contents:</span></p>
  40. <ul class="current">
  41. <li class="toctree-l1"><a class="reference internal" href="Installation.html"> Installation</a></li>
  42. <li class="toctree-l1"><a class="reference internal" href="OverviewUsage.html"> Overview</a></li>
  43. <li class="toctree-l1"><a class="reference internal" href="simpleExample.html"> First Steps</a></li>
  44. <li class="toctree-l1"><a class="reference internal" href="Structure.html"> Structure</a></li>
  45. <li class="toctree-l1"><a class="reference internal" href="ParametersConfigFile.html"> Parameters</a></li>
  46. <li class="toctree-l1"><a class="reference internal" href="SimpleAPI.html"> First API Test</a></li>
  47. <li class="toctree-l1"><a class="reference internal" href="TestTypes.html"> Types of Tests</a></li>
  48. <li class="toctree-l1"><a class="reference internal" href="DataFile.html"> Data file</a></li>
  49. <li class="toctree-l1"><a class="reference internal" href="SaveResults2Database.html"> Results in Database</a></li>
  50. <li class="toctree-l1"><a class="reference internal" href="HistoryAndReasons.html"> History</a></li>
  51. <li class="toctree-l1"><a class="reference internal" href="contributors.html"> Contributions</a></li>
  52. <li class="toctree-l1"><a class="reference internal" href="changelog.html"> Changelog</a></li>
  53. <li class="toctree-l1"><a class="reference internal" href="PlannedFeatures.html"> Planned Features</a></li>
  54. <li class="toctree-l1"><a class="reference internal" href="BrowserDrivers.html"> Browser Drivers</a></li>
  55. <li class="toctree-l1"><a class="reference internal" href="Variables.html"> Variables</a></li>
  56. <li class="toctree-l1"><a class="reference internal" href="SendStatistics.html"> Results</a></li>
  57. <li class="toctree-l1"><a class="reference internal" href="Datagenerator.html">DataGenerator</a></li>
  58. <li class="toctree-l1"><a class="reference internal" href="Datagenerator.html#input-file">Input File</a></li>
  59. <li class="toctree-l1"><a class="reference internal" href="Datagenerator.html#data-type">Data Type</a></li>
  60. <li class="toctree-l1"><a class="reference internal" href="Datagenerator.html#all-data-types-format">All Data Types Format</a></li>
  61. <li class="toctree-l1 current"><a class="current reference internal" href="#"> For Developers</a><ul>
  62. <li class="toctree-l2"><a class="reference internal" href="#subclassing">Subclassing</a></li>
  63. <li class="toctree-l2"><a class="reference internal" href="#debugging">Debugging</a></li>
  64. <li class="toctree-l2"><a class="reference internal" href="#plugins">Plugins</a></li>
  65. <li class="toctree-l2"><a class="reference internal" href="#network-trace">Network trace</a></li>
  66. <li class="toctree-l2"><a class="reference internal" href="#building-baangt-sources">Building baangt sources</a><ul>
  67. <li class="toctree-l3"><a class="reference internal" href="#building-pypi">Building pyPi</a></li>
  68. <li class="toctree-l3"><a class="reference internal" href="#building-executables">Building Executables</a><ul>
  69. <li class="toctree-l4"><a class="reference internal" href="#windows-bundle-executables">Windows bundle executables:</a></li>
  70. </ul>
  71. </li>
  72. </ul>
  73. </li>
  74. </ul>
  75. </li>
  76. <li class="toctree-l1"><a class="reference internal" href="baangt-Plugin.html">What is a baangt-plugin</a></li>
  77. <li class="toctree-l1"><a class="reference internal" href="baangt-Plugin.html#how-to-make-a-baangt-plugin">how to make a baangt-plugin</a></li>
  78. <li class="toctree-l1"><a class="reference internal" href="baangt-Plugin.html#how-the-baangt-plugin-work">how the baangt-plugin work</a></li>
  79. <li class="toctree-l1"><a class="reference internal" href="baangt-Plugin.html#how-to-replace-the-existing-plugin-by-your-own-one">how to replace the existing plugin by your own one</a></li>
  80. <li class="toctree-l1"><a class="reference internal" href="articles/Articles.html"> :subheader: Articles</a></li>
  81. <li class="toctree-l1"><a class="reference external" href="http://www.baangt.org"> Web</a></li>
  82. </ul>
  83. <p class="caption"><span class="caption-text">Autodocs:</span></p>
  84. <ul>
  85. <li class="toctree-l1"><a class="reference internal" href="docs/baangt.base.html">Autodocs</a></li>
  86. <li class="toctree-l1"><a class="reference internal" href="docs/modules.html">Modules</a></li>
  87. </ul>
  88. </div>
  89. </div>
  90. </nav>
  91. <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">
  92. <nav class="wy-nav-top" aria-label="top navigation">
  93. <i data-toggle="wy-nav-top" class="fa fa-bars"></i>
  94. <a href="index.html">baangt</a>
  95. </nav>
  96. <div class="wy-nav-content">
  97. <div class="rst-content">
  98. <div role="navigation" aria-label="breadcrumbs navigation">
  99. <ul class="wy-breadcrumbs">
  100. <li><a href="index.html">Docs</a> &raquo;</li>
  101. <li>Developer guidelines for custom enhancements</li>
  102. <li class="wy-breadcrumbs-aside">
  103. <a href="_sources/Developer.rst.txt" rel="nofollow"> View page source</a>
  104. </li>
  105. </ul>
  106. <hr/>
  107. </div>
  108. <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
  109. <div itemprop="articleBody">
  110. <div class="section" id="developer-guidelines-for-custom-enhancements">
  111. <h1>Developer guidelines for custom enhancements<a class="headerlink" href="#developer-guidelines-for-custom-enhancements" title="Permalink to this headline">¶</a></h1>
  112. <p><code class="docutils literal notranslate"><span class="pre">baangt</span></code> is already pretty versatile but from time to time you’ll face a requirement, that simply can’t be done without
  113. writing code. But that’s not a bad thing - we like writing code after all, don’t we?</p>
  114. <div class="section" id="subclassing">
  115. <h2>Subclassing<a class="headerlink" href="#subclassing" title="Permalink to this headline">¶</a></h2>
  116. <p>The main classes and functions should be more than OK for you. You’ll just need to implement some central enhancements.
  117. For instance there’s a requirement to check after each Browser-Interaction, whether a specific popup/message appeared.
  118. Don’t be cruel and let the end-users duplicate the locator over and over again in their XLSX.</p>
  119. <p>Instead create a subclass of BrowserDriver</p>
  120. <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">baangt.base.BrowserDriver</span> <span class="kn">import</span> <span class="n">BrowserHandling</span>
  121. <span class="k">class</span> <span class="nc">MyCustomBrowser</span><span class="p">(</span><span class="n">BrowserHandling</span><span class="p">)</span>
  122. <span class="k">def</span> <span class="nf">findByAndClick</span><span class="p">(</span><span class="o">...</span><span class="p">)</span>
  123. <span class="c1"># Search for the element</span>
  124. <span class="bp">self</span><span class="o">.</span><span class="n">customSearchAndReact</span><span class="p">()</span>
  125. <span class="k">def</span> <span class="nf">customSearchAndReact</span><span class="p">():</span>
  126. <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">findBy</span><span class="p">(</span><span class="n">xpath</span><span class="p">,</span> <span class="s2">&quot;specialThingForThisClient&quot;</span><span class="p">):</span>
  127. <span class="bp">self</span><span class="o">.</span><span class="n">testdataDict</span><span class="p">[</span><span class="n">GC</span><span class="o">.</span><span class="n">TESTCASESTATUS</span><span class="p">]</span> <span class="o">=</span> <span class="n">GC</span><span class="o">.</span><span class="n">TESTCASESTATUS_FAILED</span>
  128. </pre></div>
  129. </div>
  130. <p>That’s it. Business people will love you and whenever “specialThingForThisClient” changes, you’ll have to adjust only
  131. in one place.</p>
  132. <p>After subclassing you’ll need to replace the standard <code class="docutils literal notranslate"><span class="pre">BrowserHandling</span></code> with <code class="docutils literal notranslate"><span class="pre">MyCustomBrowser</span></code> in order for baangt
  133. to use it.</p>
  134. </div>
  135. <div class="section" id="debugging">
  136. <h2>Debugging<a class="headerlink" href="#debugging" title="Permalink to this headline">¶</a></h2>
  137. <p>Yeah, sometimes the logs alone are not enough, even when you set loglevel to <code class="docutils literal notranslate"><span class="pre">debug</span></code>. In such cases you’ll want to set
  138. breakpoints and expect the program to halt on the breakpoint. You’ve two chances to achieve that:</p>
  139. <ul class="simple">
  140. <li><dl class="simple">
  141. <dt>Start baangtIA.py from CLI using:</dt><dd><p><code class="docutils literal notranslate"><span class="pre">python3</span> <span class="pre">baangtIA.py</span> <span class="pre">--run=&lt;PathAndFileOfTestrunName&gt;</span> <span class="pre">--globals=&lt;PathAndFileNameForGlobals&gt;</span></code></p>
  142. </dd>
  143. </dl>
  144. </li>
  145. <li><p>Use <code class="docutils literal notranslate"><span class="pre">TX.DEBUG</span></code> as flag in <code class="docutils literal notranslate"><span class="pre">baangt</span></code> interactive starter (=the UI, that comes when you start CLI without parameter
  146. <code class="docutils literal notranslate"><span class="pre">--run</span></code>) with value <code class="docutils literal notranslate"><span class="pre">True</span></code></p></li>
  147. </ul>
  148. </div>
  149. <div class="section" id="plugins">
  150. <h2>Plugins<a class="headerlink" href="#plugins" title="Permalink to this headline">¶</a></h2>
  151. <p>Please make yourself familiar with <a class="reference external" href="https://pluggy.readthedocs.io/en/latest/">https://pluggy.readthedocs.io/en/latest/</a> in order to implement Plugins.
  152. If you’re stuck let me know.</p>
  153. </div>
  154. <div class="section" id="network-trace">
  155. <h2>Network trace<a class="headerlink" href="#network-trace" title="Permalink to this headline">¶</a></h2>
  156. <p>Sometimes it’s useful (especially for frontend debugging and in performance measurments) to have more detailed log about
  157. the calls that the browser exchanges with the backend. If you need this, use <code class="docutils literal notranslate"><span class="pre">TC.NetworkInfo</span></code> with value = <code class="docutils literal notranslate"><span class="pre">True</span></code>.
  158. In the output file you’ll see a new tab “Network” that shows all calls, headers, payload and timing information for each
  159. call.</p>
  160. <p>Use with care, as the file can get pretty big.</p>
  161. </div>
  162. <div class="section" id="building-baangt-sources">
  163. <h2>Building baangt sources<a class="headerlink" href="#building-baangt-sources" title="Permalink to this headline">¶</a></h2>
  164. <p>Core project members can build distribution as follows:</p>
  165. <div class="section" id="building-pypi">
  166. <h3>Building pyPi<a class="headerlink" href="#building-pypi" title="Permalink to this headline">¶</a></h3>
  167. <ul class="simple">
  168. <li><p>Increase version in <code class="docutils literal notranslate"><span class="pre">setup.py</span></code></p></li>
  169. <li><p><code class="docutils literal notranslate"><span class="pre">MakePackage.sh</span></code> to upload to PyPi</p></li>
  170. <li><p>Use latest version in depending project’s <code class="docutils literal notranslate"><span class="pre">requirements.txt</span></code> (Custom projects)</p></li>
  171. <li><p><code class="docutils literal notranslate"><span class="pre">pip</span> <span class="pre">install</span> <span class="pre">-r</span> <span class="pre">requirements.txt</span></code></p></li>
  172. </ul>
  173. </div>
  174. <div class="section" id="building-executables">
  175. <h3>Building Executables<a class="headerlink" href="#building-executables" title="Permalink to this headline">¶</a></h3>
  176. <ul>
  177. <li><p>Checkout <code class="docutils literal notranslate"><span class="pre">https://github.com/Athos1972/baangt-executables</span></code></p></li>
  178. <li><p>Checkout <code class="docutils literal notranslate"><span class="pre">https://gogs.earthsquad.global/athos/baangt</span></code></p></li>
  179. <li><p>Change to /baangt directory</p></li>
  180. <li><p>On a Windows computer: <code class="docutils literal notranslate"><span class="pre">execWindow.bat</span></code> (Takes about 5 Minutes)</p></li>
  181. <li><p>Move <code class="docutils literal notranslate"><span class="pre">/executables/baangt_windows_executable.zip</span></code> to checked out <code class="docutils literal notranslate"><span class="pre">baangt-executables</span></code> ideally with this line:</p>
  182. <blockquote>
  183. <div><p><code class="docutils literal notranslate"><span class="pre">mv</span> <span class="pre">executables/baangt_mac_executable.zip</span> <span class="pre">../baangt-executables</span></code></p>
  184. </div></blockquote>
  185. </li>
  186. <li><p>Repeat accordingly on Mac (<code class="docutils literal notranslate"><span class="pre">execMac.sh</span></code>)</p></li>
  187. <li><p>Repeat accordingly on Ubuntu (<code class="docutils literal notranslate"><span class="pre">execUbuntu.sh</span></code>)</p></li>
  188. <li><p><code class="docutils literal notranslate"><span class="pre">git</span> <span class="pre">add</span> <span class="pre">.</span></code> in the folder <code class="docutils literal notranslate"><span class="pre">baangt-executables</span></code></p></li>
  189. <li><p><code class="docutils literal notranslate"><span class="pre">git</span> <span class="pre">commit</span> <span class="pre">-m</span> <span class="pre">&lt;version&gt;</span></code></p></li>
  190. <li><p><code class="docutils literal notranslate"><span class="pre">git</span> <span class="pre">push</span></code></p></li>
  191. </ul>
  192. <div class="section" id="windows-bundle-executables">
  193. <h4>Windows bundle executables:<a class="headerlink" href="#windows-bundle-executables" title="Permalink to this headline">¶</a></h4>
  194. <ul class="simple">
  195. <li><p>Install innosetup-qsp (QuickStartPack) Version 6 from <a class="reference external" href="https://jrsoftware.org/isdl.php">https://jrsoftware.org/isdl.php</a></p></li>
  196. <li><p>Open Inno Setup</p></li>
  197. <li><p>Use Script <code class="docutils literal notranslate"><span class="pre">/windows/baangtSetupWindows.iss</span></code></p></li>
  198. <li><p>Check that the path for the LICENSE is correct on your computer (most probably it isn’t!)</p></li>
  199. <li><p>Execute the script using the “Compile”-Button (takes about 3-5 Minutes)</p></li>
  200. <li><p>Copy the file from <code class="docutils literal notranslate"><span class="pre">/baangt/windows/output/baangtsetup.exe</span></code> to <code class="docutils literal notranslate"><span class="pre">baangt-executables</span></code> folder</p></li>
  201. <li><p><code class="docutils literal notranslate"><span class="pre">git</span> <span class="pre">add</span> <span class="pre">.</span></code> in the folder <code class="docutils literal notranslate"><span class="pre">baangt-executables</span></code></p></li>
  202. <li><p><code class="docutils literal notranslate"><span class="pre">git</span> <span class="pre">commit</span> <span class="pre">-m</span> <span class="pre">&lt;version&gt;</span></code></p></li>
  203. <li><p><code class="docutils literal notranslate"><span class="pre">git</span> <span class="pre">push</span></code></p></li>
  204. </ul>
  205. </div>
  206. </div>
  207. </div>
  208. </div>
  209. </div>
  210. </div>
  211. <footer>
  212. <div class="rst-footer-buttons" role="navigation" aria-label="footer navigation">
  213. <a href="baangt-Plugin.html" class="btn btn-neutral float-right" title="What is a baangt-plugin" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right"></span></a>
  214. <a href="Datagenerator.html" class="btn btn-neutral float-left" title="DataGenerator" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left"></span> Previous</a>
  215. </div>
  216. <hr/>
  217. <div role="contentinfo">
  218. <p>
  219. &copy; Copyright 2020, Bernhard Buhl
  220. </p>
  221. </div>
  222. Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/rtfd/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>.
  223. </footer>
  224. </div>
  225. </div>
  226. </section>
  227. </div>
  228. <script type="text/javascript">
  229. jQuery(function () {
  230. SphinxRtdTheme.Navigation.enable(true);
  231. });
  232. </script>
  233. </body>
  234. </html>