I am executing a selenium-cucumber framework and I am having the following issue:`
org.openqa.selenium.WebDriverException: Could not convert screenshot to base64 -
Error: Unable to load canvas into base64 string -
[Exception... "Failure" nsresult: "0x80004005 (NS_ERROR_FAILURE)"
location: "JS frame :: file:///C:/Users/c38151/AppData/Local/Temp/anonymous7393315997897601641webdriver-profile/extensions/fxdriver@googlecode.com/components/driver-component.js :: fxdriver.screenshot.toBase64 :: line 10440" data: no]
Command duration or timeout: 1.13 seconds
Build info: version: '2.53.0',
revision: '35ae25b1534ae328c771e0856c93e187490ca824',
time: '2016-03-15 10:43:46'
System info: host: 'W7E1384109', ip: '172.26.31.114',
os.name: 'Windows 7',
os.arch: 'amd64',
os.version: '6.1',
java.version: '1.8.0_74'
Driver info: org.openqa.selenium.firefox.FirefoxDriver
Capabilities [{applicationCacheEnabled=true, rotatable=false, handlesAlerts=true, databaseEnabled=true, version=45.2.0, platform=WINDOWS, nativeEvents=false, acceptSslCerts=true, webStorageEnabled=true, locationContextEnabled=true, browserName=firefox, takesScreenshot=true, javascriptEnabled=true, cssSelectorsEnabled=true}]
Session ID: e48040a1-37c2-4767-a46f-acaf697dc8c4
Please let me know the soulution of this.Is this related to lo RAM?
@After public void snapShotOnFail(Scenario scenario) throws Throwable {
try {
if (scenario.isFailed()) {
final byte[] screenshot = ((TakesScreenshot) driver).getScreenshotAs(OutputType.BYTES);
scenario.embed(screenshot, "image/png");
}
} catch (WebDriverException somePlatformsDontSupportScreenshots) {
System.err.println(somePlatformsDontSupportScreenshots.getMessage());
}
}
try this and modify it as per your needs
@After
public void shutDown(Scenario scenario){
if (scenario.isFailed()) {
final byte[] screenshot = ((TakesScreenshot) Driver.getDriver()).getScreenshotAs(OutputType.BYTES);
scenario.embed(screenshot, "image/png");
}
Driver.closeDriver();
}
Try this one to error while taking screenshot.. And it could add screenshots of a failed test case in Cucumber extent report.
public void forAfterScen(Scenario scenario) throws IOException
{
if (scenario.isFailed()) {
String screenshotName = scenario.getName().replaceAll(" ", "_");
try {
TakesScreenshot ts = (TakesScreenshot) driver;
File sourcePath = ts.getScreenshotAs(OutputType.FILE);
File destinationPath = new File(System.getProperty("user.dir") + "\\Report\\" + screenshotName+".png");
Files.copy(sourcePath, destinationPath);
Reporter.addScreenCaptureFromPath(destinationPath.toString());
Reporter.addScenarioLog(screenshotName);
} catch (IOException e) {
}
}
}
User contributions licensed under CC BY-SA 3.0