How to set variable based on image

Best practices, code snippets for common functionality, examples, and guidelines.
siti
Posts: 8
Joined: Tue Oct 20, 2015 8:23 am

How to set variable based on image

Post by siti » Thu Oct 22, 2015 10:16 am

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
You do not have the required permissions to view the files attached to this post.

User avatar
RobinHood42
Posts: 324
Joined: Fri Jan 09, 2015 3:24 pm

Re: How to set variable based on image

Post by RobinHood42 » Fri Oct 23, 2015 1:30 pm

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

siti
Posts: 8
Joined: Tue Oct 20, 2015 8:23 am

Re: How to set variable based on image

Post by siti » Mon Oct 26, 2015 8:53 am

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?

User avatar
RobinHood42
Posts: 324
Joined: Fri Jan 09, 2015 3:24 pm

Re: How to set variable based on image

Post by RobinHood42 » Wed Oct 28, 2015 11:05 am

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