Developer.html 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312
  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 2020.3.0.rc4 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="index" title="Index" href="genindex.html" />
  18. <link rel="search" title="Search" href="search.html" />
  19. <link rel="next" title="Why baangt and why is it open source?" href="HistoryAndReasons.html" />
  20. <link rel="prev" title="Types of tests" href="TestTypes.html" />
  21. </head>
  22. <body class="wy-body-for-nav">
  23. <div class="wy-grid-for-nav">
  24. <nav data-toggle="wy-nav-shift" class="wy-nav-side">
  25. <div class="wy-side-scroll">
  26. <div class="wy-side-nav-search" >
  27. <a href="index.html" class="icon icon-home"> baangt
  28. </a>
  29. <div role="search">
  30. <form id="rtd-search-form" class="wy-form" action="search.html" method="get">
  31. <input type="text" name="q" placeholder="Search docs" />
  32. <input type="hidden" name="check_keywords" value="yes" />
  33. <input type="hidden" name="area" value="default" />
  34. </form>
  35. </div>
  36. </div>
  37. <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
  38. <p class="caption"><span class="caption-text">Contents:</span></p>
  39. <ul class="current">
  40. <li class="toctree-l1"><a class="reference internal" href="Installation.html"> Installation</a></li>
  41. <li class="toctree-l1"><a class="reference internal" href="OverviewUsage.html"> Overview</a></li>
  42. <li class="toctree-l1"><a class="reference internal" href="simpleExample.html"> First Steps</a></li>
  43. <li class="toctree-l1"><a class="reference internal" href="Structure.html"> Structure</a></li>
  44. <li class="toctree-l1"><a class="reference internal" href="ParametersConfigFile.html"> Parameters</a></li>
  45. <li class="toctree-l1"><a class="reference internal" href="DataFile.html"> Data file</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 current"><a class="current reference internal" href="#"> For Developers</a><ul>
  49. <li class="toctree-l2"><a class="reference internal" href="#subclassing">Subclassing</a></li>
  50. <li class="toctree-l2"><a class="reference internal" href="#debugging">Debugging</a></li>
  51. <li class="toctree-l2"><a class="reference internal" href="#plugins">Plugins</a></li>
  52. <li class="toctree-l2"><a class="reference internal" href="#network-trace">Network trace</a></li>
  53. <li class="toctree-l2"><a class="reference internal" href="#building-baangt-sources">Building baangt sources</a><ul>
  54. <li class="toctree-l3"><a class="reference internal" href="#building-pypi">Building pyPi</a></li>
  55. <li class="toctree-l3"><a class="reference internal" href="#building-executables">Building Executables</a></li>
  56. </ul>
  57. </li>
  58. </ul>
  59. </li>
  60. <li class="toctree-l1"><a class="reference internal" href="HistoryAndReasons.html"> History</a></li>
  61. <li class="toctree-l1"><a class="reference internal" href="contributors.html"> Contributions</a></li>
  62. <li class="toctree-l1"><a class="reference internal" href="changelog.html"> Changelog</a></li>
  63. <li class="toctree-l1"><a class="reference internal" href="PlannedFeatures.html"> Planned Features</a></li>
  64. <li class="toctree-l1"><a class="reference internal" href="BrowserDrivers.html"> Browser Drivers</a></li>
  65. <li class="toctree-l1"><a class="reference internal" href="articles/Articles.html"> :subheader: Articles</a></li>
  66. <li class="toctree-l1"><a class="reference external" href="http://www.baangt.org"> Web</a></li>
  67. </ul>
  68. </div>
  69. </div>
  70. </nav>
  71. <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">
  72. <nav class="wy-nav-top" aria-label="top navigation">
  73. <i data-toggle="wy-nav-top" class="fa fa-bars"></i>
  74. <a href="index.html">baangt</a>
  75. </nav>
  76. <div class="wy-nav-content">
  77. <div class="rst-content">
  78. <div role="navigation" aria-label="breadcrumbs navigation">
  79. <ul class="wy-breadcrumbs">
  80. <li><a href="index.html">Docs</a> &raquo;</li>
  81. <li>Developer guidelines for custom enhancements</li>
  82. <li class="wy-breadcrumbs-aside">
  83. <a href="_sources/Developer.rst.txt" rel="nofollow"> View page source</a>
  84. </li>
  85. </ul>
  86. <hr/>
  87. </div>
  88. <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
  89. <div itemprop="articleBody">
  90. <div class="section" id="developer-guidelines-for-custom-enhancements">
  91. <h1>Developer guidelines for custom enhancements<a class="headerlink" href="#developer-guidelines-for-custom-enhancements" title="Permalink to this headline">¶</a></h1>
  92. <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
  93. writing code. But that’s not a bad thing - we like writing code after all, don’t we?</p>
  94. <div class="section" id="subclassing">
  95. <h2>Subclassing<a class="headerlink" href="#subclassing" title="Permalink to this headline">¶</a></h2>
  96. <p>The main classes and functions should be more than OK for you. You’ll just need to implement some central enhancements.
  97. For instance there’s a requirement to check after each Browser-Interaction, whether a specific popup/message appeared.
  98. Don’t be cruel and let the end-users duplicate the locator over and over again in their XLSX.</p>
  99. <p>Instead create a subclass of BrowserDriver</p>
  100. <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>
  101. <span class="k">class</span> <span class="nc">MyCustomBrowser</span><span class="p">(</span><span class="n">BrowserHandling</span><span class="p">)</span>
  102. <span class="k">def</span> <span class="nf">findByAndClick</span><span class="p">(</span><span class="o">...</span><span class="p">)</span>
  103. <span class="c1"># Search for the element</span>
  104. <span class="bp">self</span><span class="o">.</span><span class="n">customSearchAndReact</span><span class="p">()</span>
  105. <span class="k">def</span> <span class="nf">customSearchAndReact</span><span class="p">():</span>
  106. <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>
  107. <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>
  108. </pre></div>
  109. </div>
  110. <p>That’s it. Business people will love you and whenever “specialThingForThisClient” changes, you’ll have to adjust only
  111. in one place.</p>
  112. <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
  113. to use it.</p>
  114. </div>
  115. <div class="section" id="debugging">
  116. <h2>Debugging<a class="headerlink" href="#debugging" title="Permalink to this headline">¶</a></h2>
  117. <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
  118. breakpoints and expect the program to halt on the breakpoint. You’ve two chances to achieve that:</p>
  119. <ul class="simple">
  120. <li><dl class="simple">
  121. <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>
  122. </dd>
  123. </dl>
  124. </li>
  125. <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
  126. <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>
  127. </ul>
  128. </div>
  129. <div class="section" id="plugins">
  130. <h2>Plugins<a class="headerlink" href="#plugins" title="Permalink to this headline">¶</a></h2>
  131. <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.
  132. If you’re stuck let me know.</p>
  133. </div>
  134. <div class="section" id="network-trace">
  135. <h2>Network trace<a class="headerlink" href="#network-trace" title="Permalink to this headline">¶</a></h2>
  136. <p>Sometimes it’s useful (especially for frontend debugging and in performance measurments) to have more detailed log about
  137. 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>.
  138. In the output file you’ll see a new tab “Network” that shows all calls, headers, payload and timing information for each
  139. call.</p>
  140. <p>Use with care, as the file can get pretty big.</p>
  141. </div>
  142. <div class="section" id="building-baangt-sources">
  143. <h2>Building baangt sources<a class="headerlink" href="#building-baangt-sources" title="Permalink to this headline">¶</a></h2>
  144. <p>Core project members can build distribution as follows:</p>
  145. <div class="section" id="building-pypi">
  146. <h3>Building pyPi<a class="headerlink" href="#building-pypi" title="Permalink to this headline">¶</a></h3>
  147. <ul class="simple">
  148. <li><p>Increase version in <code class="docutils literal notranslate"><span class="pre">setup.py</span></code></p></li>
  149. <li><p><code class="docutils literal notranslate"><span class="pre">MakePackage.sh</span></code> to upload to PyPi</p></li>
  150. <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>
  151. <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>
  152. </ul>
  153. </div>
  154. <div class="section" id="building-executables">
  155. <h3>Building Executables<a class="headerlink" href="#building-executables" title="Permalink to this headline">¶</a></h3>
  156. <ul>
  157. <li><p>Checkout <code class="docutils literal notranslate"><span class="pre">https://github.com/Athos1972/baangt-executables</span></code></p></li>
  158. <li><p>On a Windows computer: <code class="docutils literal notranslate"><span class="pre">execWindow.bat</span></code></p></li>
  159. <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>
  160. <blockquote>
  161. <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>
  162. </div></blockquote>
  163. </li>
  164. <li><p>Repeat accordingly on Mac (<code class="docutils literal notranslate"><span class="pre">execMac.sh</span></code>)</p></li>
  165. <li><p>Repeat accordingly on Ubuntu (<code class="docutils literal notranslate"><span class="pre">execUbuntu.sh</span></code>)</p></li>
  166. <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>
  167. <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>
  168. <li><p><code class="docutils literal notranslate"><span class="pre">git</span> <span class="pre">push</span></code></p></li>
  169. </ul>
  170. </div>
  171. </div>
  172. </div>
  173. </div>
  174. </div>
  175. <footer>
  176. <div class="rst-footer-buttons" role="navigation" aria-label="footer navigation">
  177. <a href="HistoryAndReasons.html" class="btn btn-neutral float-right" title="Why baangt and why is it open source?" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right"></span></a>
  178. <a href="TestTypes.html" class="btn btn-neutral float-left" title="Types of tests" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left"></span> Previous</a>
  179. </div>
  180. <hr/>
  181. <div role="contentinfo">
  182. <p>
  183. &copy; Copyright 2020, Bernhard Buhl
  184. </p>
  185. </div>
  186. 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>.
  187. </footer>
  188. </div>
  189. </div>
  190. </section>
  191. </div>
  192. <script type="text/javascript">
  193. jQuery(function () {
  194. SphinxRtdTheme.Navigation.enable(true);
  195. });
  196. </script>
  197. </body>
  198. </html>