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
Newsletter
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

  • AI-Era Cybersecurity, Part 1: Mapping Glasswing, Daybreak, Lightwell and the Tools Racing to Find and Fix Bugs
  • Build Software Faster With Three Simple Principles
  • Two Engines, One Query: DuckDB Inside Neo4j
  • ScyllaDB in Enterprise Java: High-Performance NoSQL With Eclipse JNoSQL

Draft This article hasn't been published, so readers can't see it.

In moderation This article is waiting for review, so readers can't see it yet.

Deleted This article has been deleted, so readers can't see it.

  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
·
Jan. 04, 21 · Analysis
Post on X (opens in a new tab) Share on LinkedIn (opens in a new tab)
8.4K Views

Join the DZone community Save articles, join the discussion, and download Refcards and Trend Reports with a free account.

Join for free Already a member? Log in

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

Loading comments

The comments didn't load

Please try again in a moment.

Likes

Loading

The next likes didn't load. Please try again.

The likes didn't load

Please try again in a moment.

See who liked this

Log in or join DZone for free to see who liked this article.

Log in Join for free
  • 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