Forum Discussion

NS189's avatar
NS189
Occasional Contributor
9 years ago
Solved

Can we add screen shot (pictures) to a folder on C drive while running test script

I need to take screen shots during execution of our test scripts and save these screen shots (aka picture) in different folders on hard drive. I have tried the Sys.Desktop.Picture(x,y,w,h) method to take the picture but I can't find a method to allow me to save

it on hard drive in specific folder. I can however, do :

     

                Regions.AddPicture(mypic,"Step_1_Pic");

 

or

               Log.AddPicture(mypic,"Step_1_Pic");

 

is there a way to put these pictures in a folder on C drive, for example, C:\myTestPics\

 

thanks

  • I think I figured it ....here is how I did it and it works for what I need to do :

     

    var filepath = "C:\\PicsLib\\f1";

    var filepicName = "dpicfile.png";

     

    //add pic

    var picname = "mypic1";

    var rpic = Sys.Desktop.Picture(10,10,1900,1001);

    Regions.AddPicture(rpic,picname);

     

    var rpicFullname = filepath+"\\"+filepicName;

    var picObj = Regions.GetPicture(picname);

    if( picObj ){

         picObj.SaveToFile(rpicFullname);

    }

     

     

2 Replies

  • NS189's avatar
    NS189
    Occasional Contributor

    I think I figured it ....here is how I did it and it works for what I need to do :

     

    var filepath = "C:\\PicsLib\\f1";

    var filepicName = "dpicfile.png";

     

    //add pic

    var picname = "mypic1";

    var rpic = Sys.Desktop.Picture(10,10,1900,1001);

    Regions.AddPicture(rpic,picname);

     

    var rpicFullname = filepath+"\\"+filepicName;

    var picObj = Regions.GetPicture(picname);

    if( picObj ){

         picObj.SaveToFile(rpicFullname);

    }

     

     

    • Raj1's avatar
      Raj1
      New Contributor

      You can do this using Regions.AddPicture itself, just that the name of the picture in Stores > Regions and the 'filepath' folder will be same.

       

      var filepath = "C:\\PicsLib\\f1";

      var filepicName = "dpicfile.png";

       

      //add pic

      var rpic = Sys.Desktop.Picture(10,10,1900,1001);

      Regions.AddPicture(filepicName, picname, false, filepath);