Calculate

Calculate

Perform calculations inside your automated tests

Modern applications are full of numbers. Prices, discounts, taxes, quantities, totals, percentages, scores, limits and thresholds all influence how your system behaves. The Calculate step allows you to perform mathematical operations directly inside your test, so you can validate logic, compare values, and generate new data without leaving DoesQA.

Instead of hard-coding expected numbers or manually working them out, you can calculate values dynamically at runtime and store the result for later use.

This keeps your tests accurate, flexible, and easier to maintain.

What you can calculate

The Calculate step supports common arithmetic operations between two values:

  • Add

  • Subtract

  • Multiply

  • Divide

  • Round

  • Floor

  • Ceil

You can combine values from:

  • The Value Store

  • API responses

  • Stored element text

  • Calculated values from previous steps

  • CI/CD passed variables

  • Scraped page content

The result is saved back into the Value Store, ready to be used by later steps in the same test.

Real-world use cases

Validate pricing logic

Confirm that:

  • Item price × quantity = basket subtotal

  • Subtotal + tax = order total

  • Discount calculations are applied correctly

  • Shipping thresholds behave as expected

Instead of checking a hard-coded number, calculate the expected value and compare it to what the UI displays.

Test financial edge cases

Validate rounding rules using:

  • Round

  • Floor

  • Ceil

For example:

  • Confirm VAT is rounded correctly

  • Ensure currency values display with correct decimal precision

  • Validate financial calculations in checkout or invoicing flows

Compare dynamic values

You can:

  • Add tax rates to dynamic basket totals

  • Calculate percentage increases or decreases

  • Validate loyalty points earned

  • Compare calculated discounts to backend values returned from an API

This makes your automation more intelligent and less brittle.

Generate derived values

Sometimes you need to compute something mid-test:

  • Create a calculated future date offset

  • Adjust numeric inputs dynamically

  • Compute totals before submitting a form

  • Calculate expected values before running a Check step

Instead of relying on static fixtures, your tests adapt to live data.

Reduce hard-coded assertions

Hard-coded numbers are one of the fastest ways to create brittle tests. When business logic changes, your automation breaks even though the system is behaving correctly.

Using Calculate helps you:

  • Align test logic with real business rules

  • Reduce maintenance

  • Avoid unnecessary failures

  • Keep tests readable and expressive

Your assertions reflect logic, not magic numbers.

Combine with other data steps

Calculate works especially well alongside:

  • Store element text

  • Store element count

  • Alias

  • API GET / POST responses

  • Dynamic values

  • Conditional branching

You can pull a value from the UI, calculate an expected result, then immediately validate it.

Build smarter tests without custom code

Many frameworks require injecting custom JavaScript just to perform basic arithmetic. With DoesQA, calculation is built-in and configurable visually.

You keep:

  • Clarity

  • Maintainability

  • Speed of creation

  • Centralised logic

Without sacrificing flexibility.

Why calculation inside automation matters

End-to-end tests should validate business behaviour, not just page structure. Financial logic, scoring rules, discount engines and thresholds are often where the real risk lives.

The Calculate step lets your automation reflect how your system actually works.

More accuracy.
Less guesswork.

Smarter coverage with minimal complexity.