Forum Discussion
- william_roeSuper Contributor
Kanika wrote:For Example - I have to fill a questionnaire having 10 questions and out of which one question also contains image which by chance fail to load during loading of questionnaire questionnaire. How can I check this scenario and can capture error image?
Try:
Log.Picture (obj.Picture(), "image");
Of course obj needs to be set. I've used this while writing code to find an object with XPath:
var obj = page.FindChildByXPath("//table[@id='grdCribPrivileges_DXMainTable']//td[text()='" + Privileges[i] + "']/parent::node()/td[@onclick]", true);
- KanikaContributor
Thanks for the reply. When I am running my script, "Has Picture" column capturing pictures of all actions performed . No matter whether it is pass or fail . I think Log. Picture() also post picture in "Has Picture" column. I dont want pictures of pass scenario and only want pictures of failed scenario . It would be better if you able to tell me how to handle failed scenario (effective way or good practice ) also with there screens.
- KanikaContributor
I think the best way of error handling is :
if obj.Exists then
.......
.......
else
str = Log.Picture(page.Picture(), "User object not found")
end if
Please suggest if there is some other way apart from this.
- anuprai29Occasional Contributor
Hi,
Try to handle event OnStopTest:
http://support.smartbear.com/viewarticle/56652/#ID0EZAnd within event handle function you can capture screen using method:
Sys.Desktop.Picture (ClientX, ClientY, Width, Height, Mouse)
and save screen capture on defined location.