AEM Test Automation - Create Pages via HTTP Requests

If you are already familiar with AEM, feel free to skip this part. If not, you should understand what this AEM is and why it is difficult to test it.





AEM - content management system Adobe ( - WordPress ). ? , (AEM-author), (Editors) , . ( publish ) (AEM-publish). , , . 





. , user interface, , . , , . , , Google , - .





, — AEM version 6.4.4.0.  , . :





  1. Screenshots tests — AEM — content management system => , , ( ).





  2. Web-component tests — UI Cypress . , .





  3. Web Performance tests — Web- ( Sitespeed)





— ( ). . , , , .





? , . . , , . , , - . 





, — . ? . — , . . .





, . . 5 , , 10+ .





?









, , , .





Long story short

, API. - , . - — ( ? — ). 





reverse engineering (AEM-author) .





, — , - - :





  1. (page template)

















  2. , , :










...





dev-tools Network. 





1.

  1. AEM-author





  2. Sites









  3. Create





  4. template









  5. Network dev-tools





  6. Create





`${aem-author-URL}/libs/wcm/core/content/sites/createpagewizard/_jcr_content



` .





. POST FormData



. .. body JSON/XML



. Content-Type: application/x-www-form-urlencoded.





JS (-, url encoded key=value



&



). , , , (key



) . .. Form Data



tags=Tag1&tags=Tag2



( , ).





[Request Example] URL encoded FormData
[Request Example] URL encoded FormData
[Request Example] Parsed FormData
[Request Example] Parsed FormData

:





  • parentPath



    — / AEM-e,





  • template



    — ,





… , …





  • ./jcr:title



    — / ( UI)





  • ./cq:tags



    — , ( )





  • ./articleDate



    , ./articleTimeToRead



    :cq_csrf_token







, .





, . , token



. cypress.io , API auth



username



password



, , body. (For more info check Cypress: Request - arguments and http-authentication).





Implementation of sending a POST request with FormData
POST FormData

key takeaways: `${aem-author-URL}/libs/wcm/core/content/sites/createpagewizard/_jcr_content



`, parentPath



template



.






2.

  1. AEM author





  2. Edit





  3. ()  





  4. +







  5. Network dev-tools









`${aem-author-URL}/content/${page-path}/jcr:content/par/${some-url-part}/par/



`.





[Request Example] Add Component to the page
[Request Example] Add Component to the page

:





  • ./@CopyFrom



    — (default) (button )





  • ./sling:resourceType



    — ,





  • parentResourceType



    — , ,






3.





  1. “ ”









  2. Network dev-tools





  3. Done





`${aem-author-URL}/content/${page-path}/_jcr_content/par/${component-name}



`.





[Request Example] Configure Component
[Request Example] Configure Component

:





  • ./sling:resourceType



    — ,





  • :cq_csrf_token



    — , auth






4.





  1. Network dev-tools





  2. Quick Publish -> Publish





4.1.

2 .





4.1.1.

reference.json… — `${aem-author-URL}/libs/wcm/core/content/reference.json?${url-params}



` — (assets), c .





[Request Example] Check Assets related to the published page
[Request Example] Check Assets related to the published page

query string params



. path



.





. path`s



, published



false



.





[Responce Example] Check Assets
[Responce Example] Check Assets

4.1.2.

replicate — `${aem-author-URL}/bin/replicate



` — .





[Request Example] Publish Page and Related Assets
[Request Example] Publish Page and Related Assets

, :





  • cmd: Activate







  • path



    — 2





4.2.

— . , .





— GET `${aem-author-URL}/etc/replication/agents.author/publish_publish/jcr:content.queue.json



`.  . , ,  body.queue



path



. , ( timeout 1 , ).






5.









  1. Network dev-tools





  2. Delete-> Delete





`${aem-author-URL}/bin/wcmcommand



`.





[Request Example] Delete Page
[Request Example] Delete Page

:





  • cmd



    — deletePage





  • path







  • force: false



    true



    ( )





  • checkChildren: true








, … 

- . — . 





FormData



. , ( ). FormData



( ).





, :





  • AEM `-



    `. `Bla 1 2 3 4



    ` , …/bla-1-2-3-4







  • lowerCase



    ( . )





  • `_



    ` ( 18 ) `_



    `. BlaBla123456789123456_blabla



    , …/blabla123456789123456_blabla



    , …/blabla123456789123456blabla







  • id



    . .








All Articles