Forum Discussion

sonya_m's avatar
SmartBear Alumni (Retired)
4 years ago

[TechCorner Challenge #13] Get properties of a web page element

Hi TestComplete Community,   A new TechCorner task today - we will be working with the DOM Document object. By completing the tasks, you can practice your skills of working with TestComplete fe...
  • prekar's avatar
    4 years ago

    Task: You will need to find the “Start a topic” button on this page and get the following info about it: color, font family, and font size and post the script and the log info below.


    This is a solution created for [TechCorner Challenge #13]

    //Solution in Javascript

    function test2()
    var url = "";

    var page = Sys.Browser().Page(url);
    var element = page.FindChildByXPath("//*[@class='NewTopic-link']");
    var style = page.contentDocument.defaultView.getComputedStyle(element, "");
    Log.Message("The Properties of web page element are as follows")
    Log.Message("Background Color : " + style.backgroundColor);
    Log.Message("Font Family : " + style.fontFamily);
    Log.Message("Font Size : " + style.fontSize);