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
Capture.JPG (10.83 KiB) Viewed 847 times
2) If image is
Capture2.JPG
Capture2.JPG (7.86 KiB) Viewed 847 times
set string status="success";
3) If image is
Capture3.JPG
Capture3.JPG (7.89 KiB) Viewed 847 times
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
Capture4.JPG (10.84 KiB) Viewed 830 times
Cheers,
Siti

Edit by Ranorex: Moved to new topic

User avatar
RobinHood42
Posts: 238
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: 238
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