Page 1 of 1

How to set variable based on image

Posted: Thu Oct 22, 2015 10:16 am
by siti
Hi,
Thanks for your reply. I have tried another approach that works for the mean time. So, I'll try the proposed method later.

I have another issue.
This is what I wanna achieve:
1) Capture the image of the status row.
Capture.JPG
2) If image is
Capture2.JPG
set string status="success";
3) If image is
Capture3.JPG
set string status="running";
and so on..

Since I'm new to Ranorex and C#, I'm totally lost especially on the image part. Hope you can help.

This is the repository
Capture4.JPG
Cheers,
Siti

Edit by Ranorex: Moved to new topic

Re: How to set variable based on image

Posted: Fri Oct 23, 2015 1:30 pm
by RobinHood42
Hi Siti,

I'm not exactly sure if working with images is the best approach to accomplish this intention, but you could use the Validate.CompareImage- method() to check if the desired image is part of your row.
for example
bool isRunning = Validate.CompareImage(repo.RootFolder.StatusRow1Info, StatusRow1_Screenshot1, StatusRow1_Screenshot1_Options, "Message", false);
    if(isRunning)
        status ="running";
More information about the Validate.CompareImage can be found in the API Documentation.

Cheers,
Robin

Re: How to set variable based on image

Posted: Mon Oct 26, 2015 8:53 am
by siti
hi,

this produced errors;

The name 'StatusRow1_Screenshot2_Options' does not exist in the current context (CS0103)
The name 'StatusRow1_Screenshot2' does not exist in the current context (CS0103)

What does this means?

Re: How to set variable based on image

Posted: Wed Oct 28, 2015 11:05 am
by RobinHood42
Hi,

Since the code I posted was a short sample, you need to adapt the code to fit your existing items.

The error itself means that the StatusRow1_Screenshot2 does not exist in the class/namespace/scope. Please find more information about the CS0103 message on the MSDN site.

Cheers,
Robin