https://cypress.io logo
Rewrite to include javascript variables in cypress...
# i-need-help
k
Greetings All, how do I retain and pass the value of the variables(index and dataTestId) to cypress commands?
Copy code
let indexInd = true;
    let index: number;
    indexInd ? (index = 0) : (index = 1);

    let dataTestIdInd = 'lyactuals'
    let dataTestId: string;
    /* Indicator to choose the Deals table according to the validation*/
    dataTestIdInd?.includes('lyactuals')
      ? (dataTestId = 'LastYearActualsTable')
      : dataTestIdInd?.includes('proposed')
      ? (dataTestId = 'ReadonlyProposedTable')
      : (dataTestId = 'SlottingBoardTable');

    cy.findByTestId(dataTestId)
      .scrollIntoView()
      .find('tfoot tr')
      .eq(index)
      .find('td'). then(() => {})