DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Related

  • Playwright: Test Automation You Must Know
  • The Hidden Cost of Flaky Tests in Test Automation
  • Selenium Test Automation Challenges: Common Pain Points and How to Solve Them
  • From Test Automation to Autonomous Quality: Designing AI Agents for Data Validation at Scale

Trending

  • Stop Choosing Sides: An Engineering Leader's Framework for Build, Buy, and Hybrid AI Agents in 2026
  • Building a RAG-Powered Bug Triage Agent With AWS Bedrock and OpenSearch k-NN
  • Reproducible Development Environments, One Command Away: Introducing CodingBooth
  • From 24 Hours to 2 Hours: How We Fixed a Broken BI System With Apache Airflow
  1. DZone
  2. Testing, Deployment, and Maintenance
  3. Testing, Tools, and Frameworks
  4. An Approach to Apply the Separation of Concern Principle in UI Test Automation

An Approach to Apply the Separation of Concern Principle in UI Test Automation

Learn about developing a test automation infrastructure based on OOP concepts.

By 
Abdelrahman Gaber user avatar
Abdelrahman Gaber
·
Jan. 04, 21 · Analysis
Likes (3)
Comment
Save
Tweet
Share
8.3K Views

Join the DZone community and get the full member experience.

Join For Free

At the beginning, let’s emphasize that automation is a kind of engineering at the core of the software industry. Basically, I’m not a quality engineer but ensuring the quality has my attention. I’ve been curious about this field in last several years and I had a chance to work with it in my last project, which is a desktop application.

We have built an automation infrastructure that is fragmented into four contexts:

The arrows demonstrate the direction of the dependency.

1. Application

The application is responsible for launching the app with the configured values, resolving the inspection third-party library and initializing a session with the app. It has an entry point for the nested views. It talks mostly technical languages and few business languages.

2. Views

It defines the views and it’s UI elements hierarchically, so each element has an owner and is composed in a parent element. It exposes the business actions and actual results. Also, it is responsible for loading the UI structure from JSON files. It talks mostly business language and a few technical languages.

For any reason, if a certain element or view has been moved to another module, all we need to do is edit its metadata to point to the new parent.

3. Tests

It has the business scenarios/assertions of the test cases. It talks only business languages.

4. Inspector

This is for inspecting the UI elements by any type. When we want to locate a specific element relative to another element or we want to inspect an operational data, i.e. items in a grid, we do that using programmatic/dynamic inspection.

To achieve that, it exposes a parametrized functionality that is needed to manipulate the UI. In our case, we wrap the usage of xpath, page-source parsing, get child elements “/*”, or get input elements by its label “/following-sibling:”.

Each time the inspector is locating an element, they do that hierarchically based on the view’s meta-data.

This context talks only in technical language.

The Design

The infrastructure is implemented based on OOP concepts, i.e. composition, abstraction, polymorphism. The following diagram demonstrates the relationship between the four contexts.

Hypothetically, the AppiumInspector is pluggable. As we see, the Inspector domain is totally hidden from Tests.

The abstraction layer is for common behavior or definitions to govern the concrete implementations.

The main window is composed in the App. It exposes a navigation functionality for the nested views. Also, it is responsible for handling the popups and any raised window during the automation.

The UI metadata file specifies the UI structure and the inspection type (i.e. AutomationId, XPath, Name, Class. or Type).

Technology stack: Appium, C#, NUnit

Conclusion

This fragmentation and the abstraction helped us at the end to write a reliable script that is pure, talks a business language, and is so close to the manual test case’s steps.

Testing Test automation Element

Opinions expressed by DZone contributors are their own.

Related

  • Playwright: Test Automation You Must Know
  • The Hidden Cost of Flaky Tests in Test Automation
  • Selenium Test Automation Challenges: Common Pain Points and How to Solve Them
  • From Test Automation to Autonomous Quality: Designing AI Agents for Data Validation at Scale

Partner Resources

×

Comments

The likes didn't load as expected. Please refresh the page and try again.

  • RSS
  • X
  • Facebook

ABOUT US

  • About DZone
  • Support and feedback
  • Community research

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 215
  • Nashville, TN 37211
  • [email protected]

Let's be friends:

  • RSS
  • X
  • Facebook