Working with colour data in WPF application

6 posts, 1 answers
  1. Stanislav
    Stanislav avatar
    1 posts
    Member since:
    May 2012

    Posted 11 Apr 2013 Link to this post

    Hello Telerik,

    Is there any functionality in Telerik testing framework to work with colour data in WPF application?
    I need the following:
    1. To be able to get colour information by specifying x and y of mouse coords;
    2. Check that the difference between two colours is not more than some value (for example, there is a red color and gray red, and the method returns true or some value).

    Thank you.

    Kind Regards,
    Stanislav Hordiyenko
  2. Velin Koychev
    Admin
    Velin Koychev avatar
    88 posts

    Posted 11 Apr 2013 Link to this post

    Hi Stanislav,

    Thank you for contacting Telerik Support.
    1) I am afraid, this is still not possible with Telerik Testing Framework.
    As you might remember, a few months ago, after your request, we logged a feature request for implementing  ElementFromPoint() method for WPF.  Unfortunately it is still not implemented. 
    In order to get color information for WPF application, you need to know the FrameworkElement.
    So it gets specific for the actual application that you want to test. 

    2)  In order to do this, you will need to write your own method or search for a method that might work for you. Here you may find useful information and more links.

    Please don't hesitate if you have additional questions.

    Greetings,
    Velin Koychev
    the Telerik team
    Quickly become an expert in Test Studio, check out our new training sessions!
    Test Studio Trainings
  3. Stanislav
    Stanislav avatar
    1 posts
    Member since:
    May 2012

    Posted 15 Apr 2013 Link to this post

    Hello Velin,

    I was able to implement a workaround. The framework element contains a method: .Capture() which returns the bitmap of the element. Then, I can read color information with .GetPixel() method.

    I do remember that in Telerik testing framework there are several methods to compare images (with some threshold) but I can't find them. There is an image, and because of the issue with .Source property I can't read its URI. Can you help me to recall them?

    Thank you.

    Kind Regards,
    Stanislav Hordiyenko
  4. Answer
    Velin Koychev
    Admin
    Velin Koychev avatar
    88 posts

    Posted 16 Apr 2013 Link to this post

    Hello Stanislav,

    Great that you have managed to find a workaround for this. 

    Indeed Telerik Testing Framework has several methods for comparing images.

    ArtOfTest.Common.CompareUtils.ImageCompare (Bitmap imageA, Bitmap imageB, Rectangle selectionArea, int tolerance)
     - performs a compare of two images and returns whether they are the same within a specific tolerance. You can also define the area within the image to compare. It returns a bool value.

    You can also use:
    ArtOfTest.Common.CompareUtils.ImageExactCompare(Bitmap imageA, Bitmap imageB)
    -It validates whether two images are exactly the same. Also returns a bool value.

    Unfortunately there is no workaround for the .Source property issue.

    All the best,
    Velin Koychev
    the Telerik team
    Quickly become an expert in Test Studio, check out our new training sessions!
    Test Studio Trainings
  5. Stanislav
    Stanislav avatar
    1 posts
    Member since:
    May 2012

    Posted 16 Apr 2013 Link to this post

    Hello Velin,

    Thank you. It is working as you described.

    Kind Regards,
    Stanislav Hordiyenko
  6. Velin Koychev
    Admin
    Velin Koychev avatar
    88 posts

    Posted 18 Apr 2013 Link to this post

    Hi Stanislav,

    It is good to hear that I have helped. Let me know if you need further help.

    All the best,
    Velin Koychev
    the Telerik team
    Quickly become an expert in Test Studio, check out our new training sessions!
    Test Studio Trainings
Back to Top