narrow-answer-2036
11/04/2021, 9:08 PMnarrow-answer-2036
11/04/2021, 9:08 PMbitter-fountain-36713
11/04/2021, 9:42 PMflaky-television-87833
11/06/2021, 1:26 PMflaky-television-87833
11/06/2021, 1:27 PMflaky-television-87833
11/06/2021, 1:28 PMcy.intercept(
{
method: 'POST', // Route all POST requests
url: 'https://api.database.com/username_password', // that have a URL that matches '/users/*'
},
[] // and force the response to be: []
).as('User has been registered') // and assign an alias
cy.wait(['@User has been registered'])
here's the codefancy-airplane-60156
11/07/2021, 10:10 AMcalm-doctor-58650
11/08/2021, 1:48 PMflaky-television-87833
11/08/2021, 5:36 PMflaky-television-87833
11/08/2021, 5:38 PMcreamy-train-56346
11/09/2021, 3:09 PMshould
command. Here is one case (I will simplify it a bit).
There is a form that has two two div elements - first (country field
) has input of autocomplete type. Second one's (state field
) input is initially simple text input, but it's final type depends on `country field`'s content:
a) if country field
!= Germany, then state field
is simple input
b) if country field
== Germany, then state field
becomes a single select list
Now, I want to check whether state field
type is changing correctly. I spotted that initially state field
has type attribute equal to text
. Type attribute changes to hidden
when it becomes a list. So I came up with following assertion:
cy.get(stateField).find('input').invoke('attr', 'type').should('eq', 'hidden');
but no mater what I do, it always results in error:calm-doctor-58650
11/09/2021, 4:57 PMcreamy-train-56346
11/10/2021, 11:32 AMcreamy-train-56346
11/10/2021, 11:36 AMthen()
- I was simply checking whether chaining is going to solve my problem. Thought that maybe Cypress is checking state field to quickly.calm-doctor-58650
11/10/2021, 2:14 PMfast-mechanic-74018
11/11/2021, 11:03 AMfast-mechanic-74018
11/11/2021, 11:03 AMcreamy-train-56346
11/11/2021, 3:08 PMstate field
worked, but it showed me error in my ways. The problem was, that user's input was still focused on country field
, hence trigger for changing `state field`'s input type wasn't send. I solved it by "clicking" somewhere else in the DOM.
But about this .invoke() vs .its()... I tried using .its() like you suggested, but Cypress for some reason can't find input's type at all. I'll attach some screenshot showing this. I tried solving this with increasing timeout for .its(), but it failed as well. Anyway I can work without solving this, but I have a feeling it can bite me in the future as well šacoustic-flag-62377
11/12/2021, 12:03 AMcalm-doctor-58650
11/12/2021, 4:36 PMfancy-airplane-60156
11/15/2021, 10:58 AMcreamy-train-56346
11/16/2021, 12:07 PMcalm-doctor-58650
11/16/2021, 6:50 PMcalm-doctor-58650
11/16/2021, 6:53 PMfancy-airplane-60156
11/17/2021, 10:47 AMjolly-parrot-71765
11/17/2021, 10:51 AMjolly-parrot-71765
11/17/2021, 10:51 AMjolly-parrot-71765
11/17/2021, 10:52 AMmodern-dress-52195
11/17/2021, 11:20 AMjolly-parrot-71765
11/17/2021, 2:15 PM