Page 1 of 2 12 LastLast
Results 1 to 10 of 12
  1. #1

    How to use Getcomputedstyle


    To check the color of a webelement in our application I am using the following code:

    Browser(sBrowser).Page(sPage).WebElement(sObject). Object.CurrentStyle.backgroundColor

    Works perfectly in IE, but we are now supporting Chrome and Firefox and this is not working when we run our tests in those browsers. I read somewhere that Getcomputedstyle could solve my problem and I can use that instead of CurrentStyle.

    I tried to find some information about it in combination with QTP or UFT but I could not find an example.

    Can someone give me some kind of an example how I can use it in a UFT script? At the moment I dont have a clue but perhaps if someone can point me in the right direction, I can solve this issue.

    Thanks in advance for your time and hopefully your reply :-)

  2. #2
    I used Google to search for "getcomputedstyle vbscript" (since VBScript is the language of QTP/UFT) and found the following:
    Trudy C
    (Opinions and information contained in this post are wholly my own and do not reflect the opinions of my employer.)

  3. #3
    I found that as well, I can Google too. But if you look closely you will see that page 430 is not part of the book preview, which means the example is not present so that link wont help me much.

    Have you found anything else, but then with an example?

  4. #4
    Can nobody give me some kind of an example?

    Is there another way of checking the background color of a WebElement in Chrome? Or is every test automation engineer just saying: Not possible.

    A little help will be appreciated.

  5. #5
    QTP is intended and largely used as a functional test tool. Sure you can do some ui color checking and such with it. But there's not good ROI on that so it's a rare practice. Throw in testing old versions of Chrome with it and you very well may be the only person attempting this and talking about it. May have to buy that book.

  6. #6
    SQA Knight bklabel1's Avatar
    Join Date
    Sep 2012
    Kew Gardens, United States
    There may be a way to get the handle of the object on the browser.
    Then use the API to ask questions about the color of the object.
    I have seen this for other browsers and non-browser objects.
    I don't remember how to do it. Does anyone else know this way?

  7. #7
    Advanced Member
    Join Date
    Aug 2004
    Wellington, New Zealand
    Why don't you try using 'Insight' (UFT 11.5+).
    Insight is more modern (and useful) implementation of the old bitmap checkpoint and therefore is colour/shape sensitive.
    Depending on the variation in background colour for your object, you may find it works very well, or it may pass too easily (it can be surprisingly change tolerant).

    ... just another Tester ...

  8. #8
    Join Date
    Sep 2001
    Doncaster, UK
    I agree with the 'no ROI' statement. For 'look & feel' you can't beat the old mark one eyeball which can scan a whole page in a matter of seconds as opposed to the number of hours it would take to automate the same checks.

    Mark Smith.

  9. #9
    SQA Knight bklabel1's Avatar
    Join Date
    Sep 2012
    Kew Gardens, United States
    I like a product from Tevron. It is called CitraTest. I haven't used it since 2001, but it is still around. I wish that HP would purchase this product and add use it to improve their insight features. It is good at recognizing parts of the screen on the bitmap level.

    This is my own opinion and does not reflect anyone that I work with or for.



  10. #10

    Here you go :-)

    Set webElem = Browser("B").Page("P").WebElement("W").Object
    Set compStyle = Browser("B").Page("P").Object.defaultView.getCompu tedStyle(webElem, "")
    bgColor = CompStyle.getPropertyValue("background-color")
    Print bgColor


Page 1 of 2 12 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
BetaSoft Inc.
All times are GMT -8. The time now is 05:44 PM.

Copyright BetaSoft Inc.