How to determine a video not exist for an existing object

Technology specific object identification, supported applications, web technologies, and 3rd party controls.
rastek
Posts: 157
Joined: Wed Aug 06, 2014 12:00 pm

How to determine a video not exist for an existing object

Post by rastek » Sun Jan 29, 2017 3:16 pm

Hi,

Validate step gives success for the object even it there is video on screen, however code below (for getting video for success scenario) step fails when there is no video.

So how can I change this code for using not video exist ? I looked at methods but can not find useful for me.

Bitmap bmp = Imaging.CaptureImage(repo.JSLAPICallExample.BlobHttpsMulti2lbNetasComTr18581);
Last edited by rastek on Mon Jan 30, 2017 2:14 pm, edited 1 time in total.

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 3914
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: How to determine a video not exist for an existing object

Post by odklizec » Mon Jan 30, 2017 9:11 am

Hi,

I'm not quite sure what exactly you want to do and without at least a Ranorex snapshot, it's very hard to suggest something reliable. But if you simply want to validate an element does not contain a video and the Imaging.CaptureImage fails if there is no video available, then I would suggest to enclose the method in Try...Catch block. This way you can suppress the exception and simply "validate" that the video is NOT available. For example, you can try something like this...

Code: Select all

    try  
    {   
        Bitmap bmp = Imaging.CaptureImage(repo.JSLAPICallExample.BlobHttpsMulti2lbNetasComTr18581);
    }  
        catch (RanorexException e)  
    {  
        Report.Success("Video is not available."); //process the exception here 
    }  
Last edited by odklizec on Mon Jan 30, 2017 12:11 pm, edited 1 time in total.
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration

rastek
Posts: 157
Joined: Wed Aug 06, 2014 12:00 pm

Re: How to determine a video not exist for an existing object

Post by rastek » Mon Jan 30, 2017 12:04 pm

Thanks odklizec, that helped!

By the way is there an option to mark a post as solved ?

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 3914
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: How to determine a video not exist for an existing object

Post by odklizec » Mon Jan 30, 2017 12:13 pm

I'm glad it helped ;) And no, I don't think there is a way to mark the forum post as "solved". But you can always edit your initial post and add "SOLVED" to the subject line ;)
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration

rastek
Posts: 157
Joined: Wed Aug 06, 2014 12:00 pm

Re: How to determine a video not exist for an existing object

Post by rastek » Mon Jan 30, 2017 1:49 pm

And an additional question, how can I modify code so that it reports error when there is video, because "no video" case is working with your code but this time there is no error for faulty situation (in which there is video and bmp can be saved.)

User avatar
N612
Posts: 62
Joined: Mon Jul 11, 2016 4:01 pm

Re: How to determine a video not exist for an existing object

Post by N612 » Mon Jan 30, 2017 10:02 pm

rastek wrote:And an additional question, how can I modify code so that it reports error when there is video, because "no video" case is working with your code but this time there is no error for faulty situation (in which there is video and bmp can be saved.)
You can use one of the following. The report.fail will only report it failed, and continue the test case, while the validate.fail will stop your test (depending on your error behavior).

Code: Select all

Report.Failure("Video is not available.");

Code: Select all

Validate.Fail("Video is not available.");

rastek
Posts: 157
Joined: Wed Aug 06, 2014 12:00 pm

Re: How to determine a video not exist for an existing object

Post by rastek » Thu Feb 02, 2017 9:13 am

The question I was asking is that how will I modify code for both situation ? after try-catch block ?

try
{
Bitmap bmp = Imaging.CaptureImage(repo.JSLAPICallExample.BlobHttpsMulti2lbNetasComTr18581);
}
catch (RanorexException e)
{
Report.Success("Video is not available."); //process the exception here
}


Validate.Fail("Video is not available.");

User avatar
N612
Posts: 62
Joined: Mon Jul 11, 2016 4:01 pm

Re: How to determine a video not exist for an existing object

Post by N612 » Mon Feb 06, 2017 7:03 pm

rastek wrote:The question I was asking is that how will I modify code for both situation ? after try-catch block ?
I don't fully understand the question. Are you wanting to report.failure if the BMP exist, and report.success if not? If so, the following should help.

Code: Select all

try
{
     Bitmap bmp = Imaging.CaptureImage(repo.JSLAPICallExample.BlobHttpsMulti2lbNetasComTr18581);
     Report.Failure("Video is available.");
}
catch (RanorexException e)
{
     Report.Success("Video is not available."); //process the exception here
}