Page Transactions as a new way to organize your testing automation

<h2>The pattern</h2> <p><strong>Guar&aacute;</strong> is the Python implementation of the design pattern <strong>Page Transactions</strong>. It is more of a programming pattern than a tool. As a pattern, it can be bound to any driver other than Selenium including the ones used to Linux, Window and Mobile automation.</p> <p>The intent of this pattern is to simplify test automation. It was inspired by Page Objects, App Actions, and Screenplay. Page Transactions focus on the operations (transactions) a user can perform on an application, such as Login, Logout, or Submit Forms.</p> <p>&nbsp;</p> <h2>The Framework in action</h2> <p>This simple implementation mimics the user switching languages in a Web Page:</p> <div class="highlight js-code-highlight"> <pre> <code>from selenium import webdriver from guara.transaction import Application from guara import it, setup import home def test_language_switch(): app = Application(webdriver.Chrome()) # Open the application app.at(setup.OpenApp, url=&quot;https://example.com/&quot;) # Change language and assert app.at(home.ChangeToPortuguese).asserts(it.IsEqualTo, &quot;Conte&uacute;do em Portugu&ecirc;s&quot;) app.at(home.ChangeToEnglish).asserts(it.IsEqualTo, &quot;Content in English&quot;) # Close the application app.at(setup.CloseApp) </code></pre> <p>Each user transaction is grouped into its own class (e.g., <strong>ChangeToPortuguese</strong>) which inherits from <strong>AbstractTransaction</strong>. The tester just has to override the <strong>do</strong> method and the framework does the work.</p> <pre> <code>from guara.transaction import AbstractTransaction class ChangeToPortuguese(AbstractTransaction): def do(self, **kwargs): self._driver.find_element(By.CSS_SELECTOR, &quot;.btn-pt&quot;).click() return self._driver.find_element(By.CSS_SELECTOR, &quot;.content&quot;).text </code></pre> <p><a href="https://github.com/douglasdcm/guara" rel="noopener noreferrer" target="_blank">Try Guar&aacute; today!</a></p> <p>&nbsp;</p> </div>