PracticeQAAutomation logoPracticeQAAutomation
Cy

JavaScript · Cypress

Fantasy sports with Cypress

Pick 11 players under a 100-credit budget with a 7-per-team cap and role minimums/maximums — every blocked + explains why — then choose captain and vice-captain, save, and see your leaderboard rank.

App under test

🏏 FantasyXI

URL
/apps/fantasy
Login
player11 / Play@123
Budget
100 credits · 11 players
Per team
max 7
Multipliers
C 2× · VC 1.5×

Scenarios to automate

Work top to bottom — each one adds a new technique.

  1. 1

    Account login

    Beginner

    Username + password (fx-login-id, fx-password, fx-login). Teams and rank belong to the signed-in account; fx-logout signs out.

  2. 2

    Counters

    Beginner

    Each pick updates players-selected, credits-left, count-IND/AUS and role-count-*.

  3. 3

    Disabled with a reason

    Intermediate

    When a rule blocks a player, pick-<id> is disabled and its title / block-<id> text says why.

  4. 4

    Budget rule

    Intermediate

    Pick expensive players until “Not enough credits” appears.

  5. 5

    Team cap

    Intermediate

    After 7 IND players, every other IND pick is blocked.

  6. 6

    Role limits

    Advanced

    Role max and “leave room for other roles' minimums” both block picks — test both.

  7. 7

    Captain rules

    Intermediate

    The same player can't be both C and VC; projected-points recalculates with multipliers.

  8. 8

    Countdown lock

    Advanced

    lock-countdown-* ticks every second; the semi-final shows locked-m2 and a disabled button.

  9. 9

    Leaderboard sort

    Beginner

    sort-points toggles order and aria-sort; your team is highlighted with my-rank.

Sample Cypress suite

A working starting point that finds elements every way Cypress can — by role, label, text, id, name, CSS, XPath and data-testid — so you practice them all. Pick your language, switch to data-testid only to compare, or try your own in the Locator Playground.

Language

Cypress runs inside the browser, so it only supports JavaScript and TypeScript — there is no Python, Java or C# version of Cypress. For those languages, see Selenium or Playwright.

fantasyxi.cy.js
// Uses the getByTestId custom command from the Cypress setup (cypress/support/commands.js).
// Locators in this suite: cy.contains ×3 · #id ×2 · [name] ×1 · getByTestId ×25
describe('FantasyXI — fantasy sports', () => {
  it('builds a valid XI and checks its rank', () => {
    cy.visit('/apps/fantasy');

    // Sign in first
    cy.get('#fx-login-id').type('player11');
    cy.get('[name="fx-password"]').type('Play@123');
    cy.contains('button', 'Sign in').click();
    cy.getByTestId('create-team-m1').click();
    cy.getByTestId('role-wk').click();
    cy.getByTestId('pick-ind-wk1').click();
    cy.getByTestId('role-bat').click();
    cy.getByTestId('pick-ind-b2').click();
    cy.getByTestId('pick-ind-b4').click();
    cy.getByTestId('pick-aus-b1').click();
    cy.getByTestId('pick-aus-b4').click();
    cy.getByTestId('role-ar').click();
    cy.getByTestId('pick-ind-ar1').click();
    cy.getByTestId('pick-aus-ar2').click();
    cy.getByTestId('role-bowl').click();
    cy.getByTestId('pick-ind-bo1').click();
    cy.getByTestId('pick-ind-bo3').click();
    cy.getByTestId('pick-aus-bo3').click();
    cy.getByTestId('pick-ind-bo4').click();
    cy.getByTestId('players-selected').should('contain', '11/11');
    cy.getByTestId('credits-left').should('contain', '0.0');
    cy.getByTestId('count-IND').should('contain', '7');
    cy.getByTestId('next-captain').click();
    cy.getByTestId('captain-ind-ar1').click();
    cy.getByTestId('vc-aus-b1').click();
    cy.getByTestId('projected-points').should('contain', '865');
    cy.get('#team-name').type('Amir XI');
    cy.contains('button', 'Save team').click();
    cy.getByTestId('team-points').should('contain', '865');
    cy.contains('a', 'Leaderboard').click();
    cy.getByTestId('my-rank').should('contain', '#6');
  });
});

Practicing another tool?