Selenium.captureEntirePageScreenshot doesn't work but selenium.captureScreenshot works

I am running selenium from TestNG using Eclipse and Selenium RC. I used the command:

selenium.captureEntirePageScreenshot("\\test.png","");

      

but got the following error:

com.thoughtworks.selenium.SeleniumException: ERROR: Command execution failure. Please search the forum at http://clearspace.openqa.org for error details from the log window.  The error message is: Component returned failure code: 0x80520001 (NS_ERROR_FILE_UNRECOGNIZED_PATH) [nsILocalFile.initWithPath]

      



Can someone please ask why this error is happening? I've already tried the following:

1) Replaced "(String kwargs parameter) with" background = # CCFFDD "

2) Working in Firefox mode in chrome mode

3) Changed the path to the following values ​​and I still get the error: "\ Test.jpg", "C: \ test.jpg", "C: \ test.png", "c: \ folder1 \ test.png" , (folder1 exists) "C: \ folder1 \ test.jpg",

4) Tried it - selenium.captureScreenshot ("\ test.png"); and it works fine, but that doesn't solve my purpose and I don't want to use awt.

Can anyone suggest what might be wrong?

Thanks,
Mugen

+2


source to share


4 answers


To whom this may apply. the problem was resolved after I continued messing with the code for a while and restarted my system. I found out that captureEntirePageScreenshot only works on absolute paths, so I made sure to keep trying exactly that.



0


source


Try the following:



String path = System.getProperty("user.dir");
selenium.captureEntirePageScreenshot(path + "\\test.png", "");

      

+1


source


Better...

I ran into a similar problem where I only had access to a relative path, not an absolute one. Here is the solution I came up with:

public void saveScreenshot(String methodName) {
    if (methodName == null) {
        methodName = String.valueOf(System.currentTimeMillis());
    }
    File f = new File("reports" + File.separator + methodName + ".jpg");
    selenium.captureEntirePageScreenshot(f.getAbsolutePath(), "");
}

      

A screenshot of the entire page will be placed in the directory reports

associated with the project. I use the method name as the filename or the current time if null is sent to the method.

+1


source


-1


source







All Articles