Overview

The Start Condition step allows you to create conditional logic in your tests by beginning a conditional block that executes contained steps only when specific conditions are met. When you add a Start Condition step, an End Condition step is automatically added to close the conditional block.

Form Fields

Field NameTypeRequiredDescription
Check ifselectYesChoose between Element or Supatest Variable
Element/Variableinput/selectYesElement locator or variable name to check
OperationselectYesComparison operator for the condition
Expected ValueinputOptionalValue to compare against (when required)

Form Configuration

Subject Selection

Choose what to evaluate in your condition:

Element Option

  • Element Locator: CSS selector or element picker for targeting page elements
  • Use Element Picker: Visual selection tool for precise element targeting
  • Locator English Description: Human-readable description of the selected element

Supatest Variable Option

  • Variable Dropdown: Select from previously created Supatest variables
  • Variable Reference: Variables are referenced with $ prefix (e.g., $userEmail)

Operation Types

Available operations depend on the subject type:

For Elements

  • Is Visible: Check if element is visible on the page
  • Is Not Visible: Check if element is hidden or not present
  • Has Text: Check if element contains specific text content
  • Does Not Have Text: Check if element doesn’t contain specific text

For Variables

  • Equals: Check if variable value exactly matches expected value
  • Not Equals: Check if variable value doesn’t match expected value

Expected Value Field

  • Conditional Display: Only shown when operation requires comparison
  • Required for: “Has Text”, “Does Not Have Text”, “Equals”, “Not Equals”
  • Not Required for: “Is Visible”, “Is Not Visible”
  • Text Input: Free-form text for comparison values

Examples

Element Visibility Condition

Check if error message appears before showing retry option:
  • Check if: Element
  • Element: .error-message (Error message container)
  • Operation: Is Visible
  • Expected Value: (not required)
Steps inside condition:
  1. Click “Retry” button
  2. Fill form fields again
  3. Submit form

Element Text Content Condition

Check if status shows “Pending” before waiting:
  • Check if: Element
  • Element: #order-status (Order status display)
  • Operation: Has Text
  • Expected Value: Pending
Steps inside condition:
  1. Wait 30 seconds
  2. Refresh page
  3. Check status again

Variable Value Condition

Check if user role equals “admin” before accessing admin features:
  • Check if: Supatest Variable
  • Variable: userRole
  • Operation: Equals
  • Expected Value: admin
Steps inside condition:
  1. Click “Admin Panel” button
  2. Verify admin dashboard loads
  3. Access user management

Variable Inequality Condition

Check if attempt count is not zero before retrying:
  • Check if: Supatest Variable
  • Variable: attemptCount
  • Operation: Not Equals
  • Expected Value: 0
Steps inside condition:
  1. Display retry button
  2. Reset form validation
  3. Enable form submission

Negative Element Condition

Check if loading spinner is not visible before proceeding:
  • Check if: Element
  • Element: .loading-spinner (Loading indicator)
  • Operation: Is Not Visible
  • Expected Value: (not required)
Steps inside condition:
  1. Click “Continue” button
  2. Fill next form section
  3. Proceed to next step

Best Practices

Condition Design

  • Clear Conditions: Use specific, reliable conditions that clearly indicate when steps should execute
  • Stable Elements: Target elements with stable selectors that won’t change frequently
  • Meaningful Variables: Use descriptive variable names that clearly indicate their purpose
  • Avoid Complex Logic: Keep conditions simple and focused on single criteria

Element Selection

  • Unique Selectors: Use CSS selectors that uniquely identify the target element
  • Stable Attributes: Prefer data-testid or other stable attributes over dynamic classes
  • Visible Elements: Ensure targeted elements are consistently visible when condition should be true
  • Error Handling: Plan for scenarios where elements might not be present

Variable Usage

  • Pre-existing Variables: Ensure variables are created and assigned before conditional checks
  • Consistent Values: Use consistent value formats for reliable comparisons
  • Case Sensitivity: Remember that string comparisons are case-sensitive
  • Type Consistency: Ensure variable values match expected data types

Scope Management

  • Logical Grouping: Group related steps that should execute together under the same condition
  • Minimal Scope: Keep conditional blocks as small and focused as possible
  • Clear Boundaries: Ensure the end condition properly closes the conditional block
  • Nested Conditions: Avoid overly complex nested conditional logic

Common Use Cases

Error Handling

Handle error scenarios that may or may not appear:
Start Condition: If error message is visible
├── Display error details
├── Log error information
├── Click retry button
└── Reset form state
End Condition

Feature Availability

Execute steps only when features are available:
Start Condition: If premium features button is visible
├── Click premium features
├── Verify premium dashboard
├── Test premium functionality
└── Log premium usage
End Condition

User Role-Based Testing

Test different flows based on user permissions:
Start Condition: If userRole equals "moderator"
├── Access moderation panel
├── Review pending content
├── Approve/reject items
└── Verify moderation logs
End Condition

Dynamic Content Handling

Handle content that appears conditionally:
Start Condition: If notification banner has text "Update Available"
├── Click "Update Now" button
├── Wait for update process
├── Verify update completion
└── Dismiss notification
End Condition

Multi-Path Workflows

Handle different workflow paths:
Start Condition: If payment method equals "credit_card"
├── Fill credit card details
├── Enter billing address
├── Verify card information
└── Process credit payment
End Condition

Start Condition: If payment method equals "paypal"
├── Click PayPal button
├── Login to PayPal
├── Confirm payment
└── Return to merchant
End Condition

Technical Implementation

Conditional Logic Structure

The Start Condition step creates a conditional block structure:
Start Condition (defines criteria)
├── Step 1 (executes only if condition is true)
├── Step 2 (executes only if condition is true)
├── Step N (executes only if condition is true)
End Condition (automatically added to close the block)

Execution Behavior

  • Condition Evaluation: Start Condition is evaluated before executing contained steps
  • True Condition: If condition is true, all steps between Start and End Condition execute
  • False Condition: If condition is false, all steps between Start and End Condition are skipped
  • Automatic Pairing: End Condition is automatically added when you create a Start Condition

Generated Code Structure

The Start Condition step generates Playwright code similar to:
// Element visibility condition
const condition = await page.locator('#error-message').isVisible();
if (condition) {
  // Conditional steps execute here
  await page.click('[data-testid="retry-button"]');
  await page.fill('#email', 'user@example.com');
  await page.click('[type="submit"]');
}

// Variable equality condition
const condition = supatestVars['userRole'] === 'admin';
if (condition) {
  // Admin-specific steps execute here
  await page.click('#admin-panel');
  await expect(page.locator('h1')).toHaveText('Admin Dashboard');
}

Advanced Features

Variable Integration

  • Pre-Condition Variables: Use variables created in earlier steps for condition evaluation
  • Post-Condition Variables: Create variables within conditional blocks for later use
  • Dynamic Conditions: Build conditions based on runtime values and user interactions

Element Picker Integration

  • Visual Selection: Use element picker for precise element targeting
  • Real-time Validation: Validate element selectors during condition setup
  • English Descriptions: Generate human-readable descriptions for selected elements

Form Validation

  • Real-time Feedback: Form validates condition configuration as you type
  • Required Fields: Automatically enforces required fields based on operation type
  • Error Messages: Clear error messages for incomplete or invalid configurations

Common Issues

Condition Never True

  • Problem: Conditional steps never execute because condition is always false
  • Solution: Verify element selectors and expected values are correct
  • Debugging: Test condition criteria manually to ensure they can be satisfied

Condition Always True

  • Problem: Conditional steps always execute when they should be conditional
  • Solution: Review condition logic and ensure it properly evaluates to false when expected
  • Checking: Verify the opposite condition works as expected

Missing End Condition

  • Problem: Conditional block extends beyond intended scope
  • Solution: Ensure every start condition has a corresponding end condition
  • Validation: The system automatically validates balanced conditional blocks

Variable Not Found

  • Problem: Condition references variables that don’t exist
  • Solution: Ensure variables are created and assigned before conditional evaluation
  • Verification: Check that variable creation steps execute successfully

Element Timing Issues

  • Problem: Elements used in conditions may not be ready when evaluated
  • Solution: Add wait conditions before conditional steps if elements load dynamically
  • Timing: Consider page load timing when setting up element-based conditions

Performance Considerations

Efficient Conditions

  • Fast Evaluation: Design conditions that can be evaluated quickly
  • Minimal DOM Queries: Use efficient CSS selectors that don’t require extensive DOM traversal
  • Cached Elements: Consider element stability to avoid repeated selector evaluation

Scope Optimization

  • Minimal Blocks: Keep conditional blocks small to reduce overhead when conditions are false
  • Early Exit: Design conditions that fail fast when criteria aren’t met
  • Resource Usage: Consider the performance impact of skipped steps vs. executed steps
  • End Condition - For manually closing conditional blocks when needed
  • Extract Value - For creating variables used in conditional evaluation
  • Wait for Element - For ensuring elements are ready before condition evaluation
  • Verify Visibility - For similar element visibility checking outside conditions
  • Verify Value - For similar text content verification outside conditions