ylliX - Online Advertising Network
Vertex AI - Antrophic and Mistral models: Why does it require Imegen access?

How do I parse a value from a data attribute in Cypress?


I have an input field:

<input type="range" id="amtRange" value="0" min="280" max="1400">

I want to get the value of the min attribute and see if it is less than another pre-existing value, eg:

The amount in the min attribute (280) should be less than the number in the ‘amt’ variable.

I can get the value as a string as such:

cy.get('#amtRange').invoke('attr', 'min');

But cannot figure out how to pass it as an integer. I have tried the following:

const amt = 286;
let minAmt = cy.get('#amtRange').invoke('attr', 'min');
minAmt = parseInt(minAmt);
minAmt.should('be.lessThan', amt);

But this produces the error: TypeError: minAmt.should is not a function.

I have also tried:

const amt = 286;
cy.get('#amtRange').then(($amtInput) => {
    let minAmt = parseInt($amtInput.invoke('attr', 'min'));
    minAmt.should('be.lessThan', amt);
});

But this produces the error: $amtInput.invoke is not a function.

Would anyone know how I can achieve this?



Source link

Leave a Reply

Your email address will not be published. Required fields are marked *