Posts

How verify multiple elements in as single assertion.

describe ( 'How verify multiple elements in as single assertion.' , () => {     it ( 'Check multiple elements' , () => {         const expectedList = [ '' , 'I am good' , 'ortonikc' , 'Koushik Chatterjee' , '' , 'This text is readonly' ]         cy . visit ( "https://letcode.in/edit" )         cy . get ( "[class='field'] input" ). then (( $ele ) => {             const values = Cypress . _ . chain ( $ele ). map ( 'value' ). value ()             expect ( values ). to . deep . equal ( expectedList )                         expect ( values ). to . deep . equal ( expectedList )               //if you do not want to check indexing then you can use below assertion             expect ( values ). to . include . members ( expectedList )         })     }); })

Multiple Ways Of Checking If Element Becomes Visible

Elements is visible - multiple ways  describe ( 'multiple ways to check element is visible' , () => {     it ( 'check element is visible' , () => {         cy . visit ( "https://letcode.in/buttons" )         // First appraoch         cy . get ( "[class='control']:has(button#isDisabled)" ). should ( "be.visible" )           // Second appraoch         cy . get ( "[class='control']:has(button#isDisabled)" ). should ( "satisfy" , Cypress . dom . isVisible )           // Third appraoch         cy . get ( "[class='control']:has(button#isDisabled)" ). then (( $ele ) => {             if (! Cypress . dom . isVisible ( $ele )){                 throw new Error ( 'Element is hidden or Not visible' )             }         })         }); })