Skip to main content

Posts

Showing posts with the label How to interact with CK Editors in Cypress?

How to interact with CkEditor(V4) in Cypress?

Interaction with CkEitor (V4) in Cypress:  CkEditor is a Third Party tool which is commonly used in websites. Open your ` commands.js ` file. Paste this code in it. Cypress . Commands . add ( 'iframe' , {  prevSubject :   'element'  }, ( $iframe )  =>  {      const   $iframeDoc  =  $iframe . contents ()      const   findBody  = ()  =>   $iframeDoc . find ( 'body' )      if  ( $iframeDoc . prop ( 'readyState' ) ===  'complete' )  return   findBody ()      return   Cypress . Promise (( resolve )  =>   $iframe . on ( 'load' , ()  =>   resolve ( findBody ()))) }); Cypress . Commands . add (      'iframeLoaded' , {  prevSubject :   'element'  },     ( $iframe )  =>  {          const   contentWindow  =  $iframe . prop ( 'contentWindow' )          return   new   Promise ( resolve   =>  {              if  (                  contentWindow  &&                  contentWindow . document . readyState