Skip to content
zubinix edited this page Jan 24, 2021 · 9 revisions

Why another framework?

Modern web applications and the frameworks which drive them are quite complex and involve a lot of dynamic interactions both with the server back end and with the web browser and user, often causing the browser's DOM to be rebuilt to display new UI elements.

Browser automation has relied on performing an action on the web browser and then waiting a specific amount of time or for an element to appear or disappear before performing the next action on the web browser. To do this reliably is much harder than it seems since underlying events such as network calls and DOM rebuilds can take a long time and happen in an unpredictable order.

This framework is an attempt at reducing this complexity by handling 3 types of waits transparently. It was developed with automation of Microsoft Business Central and Microsoft Dynamics NAV in mind.

  • Network wait. Browser sends request to service.
  • DOM change wait. Often a rebuild after a network operation.
  • BUSY wait – Is a timer (using setTimeout) taking longer than it should? Could indicate other busy conditions, even system busy.

More details on Synchronisation Mechanism

Example

The core method is doBrowserAction() in the WebBrowserDriver class

driver.doBrowserAction(d =>  
{  
    By sales_orders = By.Xpath(“//where the sales order button is”);  
    IWebElement sales_orders_el = d.FindElement(sales_orders);  
    sales_orders_el.Click();  
},  
actionDesc: "Click Sales Orders menu button",  
sync: WebBrowserDriver.SyncMethodEnum.AJAX);  

The code above will press the sales order button and then wait for 3 different waits (Network, DOM change, BUSY wait) to be completed.

In pseudo code the wait looks like this:

Do  
    If Network active; sleep(300ms); Go to start of loop...  
    if DOM change; sleep(300ms); Go to start of loop...  
    if BUSY wait detected; Go to start of loop...  

    // If none of the waits have occurred...
    sleep(300);  
    Network wait || DOM change || BUSY wait? => Go to start of loop...  
End  
Clone this wiki locally