geneticmaterial
4 years agoContributor
Extract datalayer JSON object from html page source testcomplete
Hi
Long time user of readyAPi etc but looking to help out with some automation of the datalayer for my employer. The system testers use testcomplete and I'm just wondering what would be the best way to extract the JSON object in the datalayer held on the html page source, should we wish to piggyback on their already written journey based tests.
This link seems to be getting me on my way but I am unsure how or where to use it.
Should it be using code snippets, logging etc?
Thanks, Dan
Now doing this should someone come across and need a solution:
function GetDigitalData(){ var page = Sys.Browser().Page("*"); var digitalData = page.contentDocument.querySelector('script[class="dataMapper"]').innerHTML; return x = digitalData.substring(23).slice(0, -2); } function PageData(){ var digitalData = GetDigitalData() //do something }