Forum Discussion

geneticmaterial's avatar
geneticmaterial
Contributor
4 years ago

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...
  • geneticmaterial's avatar
    geneticmaterial
    4 years ago

    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
    }