Service Virtualization

Expand all | Collapse all

How can I take screenshot of every webpage while executing Selenium Step?

  • 1.  How can I take screenshot of every webpage while executing Selenium Step?

    Posted Aug 01, 2016 10:07 AM

    I am executing JSON Script in CA DevTest using Selenium Step and I need to take screenshots of all the actions (or pages) when I execue my test.Can someone please help me in this regard.

     

    Thanks

    Ragini



  • 2.  Re: How can I take screenshot of every webpage while executing Selenium Step?

    Broadcom Employee
    Posted Feb 14, 2017 04:20 PM

    What version of DevTest are you on?



  • 3.  Re: How can I take screenshot of every webpage while executing Selenium Step?
    Best Answer

    Broadcom Employee
    Posted Feb 14, 2017 06:01 PM

    Every Selenium Step executed in DevTest will automatically take screenshot implicitly, and the screenshot can be viewed in the Portal.

     

    You can also create an Execute script (JSR-223) step after each Selenium step you want to save the screen on with the below code, (modify the selenium.PNG per step to save multiple screen shots)

     

    import com.itko.util.*;

    import org.apache.commons.io.*;  String screenEncoded = testExec.getStateObject("selenium.last.screenshot"); byte[] screenDecoded = Base64.decode(screenEncoded); FileUtils.writeByteArrayToFile(new File("c:\\temp\\selenium.PNG"),screenDecoded);
    Got this from Communities post: