Q & A : Design Patterns for Scalable Test Automation

Sauce AI for Test Authoring: Move from purpose to execution in minutes.|xBack to ResourcesBlogPosted

April 05, 2026 · 11 min read · Testing Guide

Sauce AI for Test Authoring: Move from purpose to execution in minutes.

|

x

Back to Resources

Blog

Posted June 23, 2016

Q & amp; A: Design Patterns for Scalable Test Automation

quote

Thanks to everyone who join the webinar yield by Sahas Subramanian, “”. There were a bit of great inquiry that were posed prior to and during the session, and we asked Sahas to consolidate some of these inquiry and reply them in this follow-up position. Disclaimer: opinions shared below are Sahas ’ and not those of his employer or Sauce Labs.

Should you have any additional questions, send a tweet to @ Sahaswaranamam.

Q: How can you outdo handle protection hallmark pop-ups from specific browsers? What are the best ways to exchange between tabs and to close tabs?

A:Use the getCurrentTabId API to get the hold of the current window. Once you have the pop-up window handle, you could close it applybrowser.close (popUpHandle)

Q: How should I handle SOAP/SOAPUI test?

A:Generally mouth, Selenium and Webdriver are appropriate for UI screen. If your intention is to test the APIs, I would suggest using tools likeJMeter and/or Taurus. Reference:http: //gettaurus.org

Q: How do I create my own wrapper? (How can I check for page title?)

Q: What are your thought on using a recording IDE versus writing your own machine-controlled scripts in terms of time efficiency, maintenance, lustiness, and efficiency?

A:While disc and replay creature can aid you get begin faster they have an inherent failing that leads to brittle tests – when the UI changes it is harder to update the generated codification since the team won ’ t know the architecture and plan behind the codification. Former limitation:

– They are often proprietary and licensed.

– Some instrument are not flexible in the regard that a small change might force you to regenerate the entire workflow.

Overall, record/replay instrument might be a good resolution for a UI that doesn ’ t change. For changing interface, well understood hand-crafted code is good from all perspectives.

Q: It was my understanding that there is no guarantee of the order in which unit tests will run. In your example you have unit test that are running one component of your workflow, but if they did not run in the order you await they would betray.

A: Mocha describes ()can manage synchronous and asynchronous execution by just passing a recall toit()block. My example usesMochaand leverages synchronous nature to orchestrate the workflow.

Q: Is there an expected status that can do foliate reload?

A:Sometimes a trial has to expect for a process to discharge, but that ingredient is not updated except on page reload.Webdriver.iooffers an API to reload/refresh the page. Check outhttp: //webdriver.io/v3.0/api/protocol/refresh.html. Depending on your workflow, try to recharge the page and use one of thewaitFor APIsfor that specific element to be visible or enable.

Q: How do you publish tests that aren ’ t fragile? How do you best introduce approaches to limit brickle integration testing and meliorate test dependability?

A:Some of my top choice:

  1. Make sure the UI examination is the right proficiency to automate the requirement. If the requirement can be tested thru View

  2. Testing or API testing, choose that over Webdriver driven UI Tests

  3. Prefer declarative vs. imperative BDD

  4. Adopt Page Object pattern and follow clear chain of responsibleness between Tests and Page Objects

  5. Prefer “ Tell Don ’ t Ask shape ”, establish the logic in Page Objects and keep exam lean

  6. Avoid Thread.Sleep and handle asynchronous behavior via code in the Page Object logic

  7. Share test logic and engineer the automation with potential code patterns & amp; principles

  8. Constantly critique and refactor test mechanization code much similar to production codification

Q: We have an old legacy app and no team adoption of test automation. Changes break things all the time. How would you suggest we talk to the team about adding exam automation to our process?

A:I would suggest to get with envision thevalue flow mapfor your delivery procedure and understand the current engineering cycle time, chokepoint, and make dissipation seeable. Additionally, try to quantify feature dev vs. bug fix travail and the number of bugs ground in production.

Typically, deficiency of automation will indicate eminent round clip, long (manual) test effort, high shortcoming rate and/or high bug define effort. With that initial measure you could work with the product and engineering leadership to improve the situation.

Q: What are some full “ quality ” measurements we can use to demonstrate labor success?

A: IMO, I don ’ t see quality/test automation as a separate try rather it ’ s part of growth. It should help to ship the production quicker with great quality. Each character of test should help to increase assurance. Given that, Value stream map before and after the effort should expose the benefits (if test automation was the bottleneck).

In gain, measure:

  • Full trial mechanization(# unit tests, # position test, # api workflow tryout, # UI workflow tests, # A/B tests). Expectation – overall movement should be up (we should be adding more automation), individual test automation technique trend should align to a pyramid.

  • Customer reported bugs. Expectation: this should be trending down

  • Automation success rate over time. Expectation: should be sheer up and remain closely to 100 %

  • Automation execution clip over time. Expectation: should be veer down

Q: How do I debar Thread.sleep ()? I ’ ve put in all kinds of waits in my code, but I still get periodic failure because some element or another can ’ t be found. Is that just something you have to live with when doing browser testing? Or is there e'er a authentic method that you can trust every time? How can we recite Webdriver to wait until Ajax is perform?

For autonomous testing across multiple user personas, check out SUSATest — it explores your app like 10 different real users.

A:Generally,thread.sleepor waits are used when the UI is waiting on an asynchronous request from the back-end. The easy way to handle the position is to use the Webdriver-providedanticipate weather class.

If your language of choice doesn ’ t have anything like ExpectedConditions stratum, I would suggest referring to howWebdriver.ioapply the like logic and try to make your own, if necessary. Soon we ’ ll have another blog post walking this thru.

Q: How can you speed up test with Sauce Labs?

A:If your test is slow due to asynchronous behavior on the app, I ’ m not sure the “ test ” can run faster than the app. We involve to look at the application performance to amend the position.

Given that the app is quicker but tests are running dense, there could be many reason. Some of the common things I would try:

  • CRUD flow– try to compound scenarios to be meaningful end-user demeanor. For example, let ’ s assume that you are essay the WordPress blogging app (create blog place, view the blog spot, verify visitor, view by geography, delete the post etc). If each one of them is an independent scenario, potentially some stairs are repeated (e.g., launching the browser, navigating to the website, logging in, navigate to posts page, etc). Instead of separate scenarios, if we combine them to be logical workflow for a given persona, repeated steps can be optimized and as a solution tests complete faster.

  • Scaled base– If all your UI tests are crucial, run them in latitude. Leverage Sauce Labs or a Selenium grid as appropriate

  • Test category & amp; parallel executing– Split the tests by different category, run them in parallel

  • Limit browser mix– From the employment prosody, learn the most widely used browser by your customers and prioritize that browser mix. We can ’ t test all scenarios across all different browsers, all the versions overtime.

  • Logging and visibility– integrate logging with some time series database,create profile, measure flakiness, slow tests trends to focus and improve.

Q: How difficult is integrate Webdriver.io with a CI waiter like Jenkins?

A:We ’ ll have another blog post on this soon. However, it ’ s fairly simple to integrate with any CI/CD scheme. In my example project, all you require to do is:

  • Checkout the source from your repo

  • Navigate to * _tests directory

  • npm install

  • npm run test-Sauce Labs

This last command above will return zero exit codification on success. Configure your system to miscarry on non-zero exit code.

Q: Are view tests part of the product code base same as unit?

A:Yes. We tag them as “ View glasses ” and run constituent of unit tests.

Q: Can Selenium support shared object repositories (a conception of UFT)? Just like LeanFT can we build upon Selenium tests using such repos?

A:I ’ ve not used either of the above name products. However, UI map can be considered as UI elements repository and shall be share via package management.

Q: What is the good way to handle timeout subject with complex UI scripts from Jenkins, e.g. timeout pass after 300 sec (haphazardly)?

A:IMO, this has less to do with Jenkins or Sauce Labs. This can be handled using the test runner (e.g., Mocha) and your try framework (e.g., Webdriver.io)

Q: Is Webdriver.IO a part of Webdriver or a different merchandise? In early language, can Webdriver.IO work with Webdriver? Is Webdriver.IO the same as Selenium Webdriver?

A:Webdriver.IO is a wrapper on top of Webdriver to control browser and mobile applications efficiently.

Q: Is there a way to do step-by-step debugging with Webdriver.io?

A: Yes:

  1. Configure your IDE for debugging node js. For example, I use VSCode – here is a reference:https: //code.visualstudio.com/Docs/editor/debugging

Q: How should logic be legislate to the configuration in WebdriverIO? For a variety of modes, e.g., multiple brand, environments, resolutions, and local vs. cloud runners?

A:Webdriver.io leverages JavaScript to have configuration parameters. You can create a lord config (generic one), environment specific configs, and commingle them at execution clip. Reference:https: //github.com/sahas-/webdriverio-examples/tree/master/googleSearch_tests/config

Q: What is the best way to implement TDM (Test Data Management)? Is it a full exercise to hardcode my information in the test itself or use an external resource like Excel, CSV?

1. Using Test DB separately.2. Generating data on the fly in code and use it.3. Use Excel spreadsheet.4. Use a TDM tool (Need Free Tool) .5. Using SQL Inserts directly into appDB.

A:IMO, I try to do # 2 as much as possible. Part of test apparatus, call the back-end service, and make necessary data. Also, blue-pencil them as part of clean up. Secondly, if we postdate CRUD workflow based attack, create the data as first step in the workflow, examination early operations such as edit, update and finally delete the record as a terminal step of the process.

Q: Which is the most commonly recommended fabric to use with Sauce Labs?

A:It ’ s hard to say. IMO, your pick of creature depends on your:

  • Goal (i.e., we demand ONE framework to try legacy app + web app + mobile app + native mobile app)

  • Development stack – should array with your development slew for developers to lead and maintain tests. Ultimately support team owns calibre rule.

Q: Why use WebdriverIO instead of Protractor? For testing an Angular-based website, how much can Selenium help? Or should I simply use Protractor by itself? How different is this model than Nightwatch.js? Is Webdriver.io a replacement/alternative to Nightwatch.js?

A:The webinar ’ s intention was to look at some practical patterns that can facilitate stabilise and scale exam automation. These patterns are applicable to almost any language of choice and it ’ ll be great if the framework of choice assist enforce these patterns. I use WebdriverIO for several reasons mentioned in the talk. You should valuate the choice of language/framework based on your finish.

Q: What is the best way to run just specific tests within our exam suite?

A:It count on the examine fabric that you have chosen. For example, I use Mocha in my example, below ——grep selection allows me to run specific tests matching a RegEx.

Q: What is the ROI for mechanization specialists spending time explaining the advantages of programming unequalled ID and NAME tags to web developer?

A:Unique ID, names do volunteer stable ways to locate and act on the ingredient. However, there could be some implementations where providing a unique ID impossible. For example, Grid component populates data dynamically ground on the answer from the backend and it ’ s not easygoing to provide a unique ID for every individual cell. Given these situations, best bet is to collaborate with the UI/HTML developer who germinate the component and let them supply you with the UI Map family since they cognize the best technique to place the constituent. This is one of the reasons I recommend separating the UI map.

Q: Does this proficiency employment with Appium for Mobile App testing?

A: Yes

Q: Should we automate all scenario included in US? If Yes, why? If no, why not?

A:You should automate as much as potential and leverage the machine to aid boosting assurance in your app. However, you should pick the appropriate automation proficiency to achieve your goal.

Q: Do you prefer a monumental construction for mobile application and website mechanization? Or is the good practice to create and acquire as separate undertaking?

A:IMO, it would be great to leverage mutual code as much as possible and motor the web/mobile workflow ground on the configuration. Less code, less maintenance.

Q: What is the good way to shorten Selenium codification except POM and PF?

A:I need a bit more circumstance. However, at a eminent degree

  1. Implement possible OOP concepts to cut down redundant codification and cut maintenance.

  2. Leverage Agile essay quadrant thoughts to rationalize the mechanisation and adapt appropriate technique. For example, survey testing can be leverage to increase automation confidence and reduce Webdriver free-base automation footprint.

Q: How good to use Selenium or WebdriverIO for microservices?

A:Microservices architecture doesn ’ t change the UI trial automation paradigm. However, I would strongly suggest you reference the book “Building Microservices” in which the author has dedicate Section 7 for Testing and briefly explain the different proficiency for stable, maintainable test mechanization.

Published:
Jun 23, 2016
Share this position
Copy Share Link
LinkedIn
© 2026 Sauce Labs Inc., all rightfield reserved. SAUCE and SAUCE LABS are file trademarks owned by Sauce Labs Inc. in the United States, EU, and may be registered in former jurisdictions.
robot
quote

Automate This With SUSA

Upload your APK or URL. SUSA explores like 10 real users — finds bugs, accessibility violations, and security issues. No scripts needed.

Try SUSA Free

Test Your App Autonomously

Upload your APK or URL. SUSA explores like 10 real users — finds bugs, accessibility violations, and security issues. No scripts.

Try SUSA Free