Reputation: 656
If I try on my local machine (Macbook)
byte[] screen = driver.takeScreenshot();
Driver:
public byte[] takeScreenshot() {
return ((TakesScreenshot) driver).getScreenshotAs(OutputType.BYTES);
}
I get
SCREENSHOT BYTES: -119807871131026100001373726882008520054886000-7418-1053100122110567678073676732801141111021051081010072 ... 66-51-53-81-71-37-7131115-33-25-66-501218163264-12801248163264-12801248163264-12801248163264-12801291446-13-31-13-36105-1856119-104-112-3112194-3361471279-107-3665110-3364000073697868-826696-126
But if I try it on Jenkins Windows slave, I get
SCREENSHOT BYTES: -1198078711310261000013737268820040002-1058600028-82566600109573686584120-100-19-63491000-62-96-11791091063 960000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000466116-201-91-24-43-101000073697868-826696-126
which is image, but blank (invisible).
I tried it in Chromedriver, Geckodriver and IE driver as well.
Upvotes: 4
Views: 8342
Reputation: 66
I met almost the same problem and resolved it by updating my Chrome from version 59.0.3071.115 to Google Chrome beta v60.0.3112.40.
My problem is that Selenium screenshot works good locally but only takes blank screenshot on Jenkins since last week. This is the screenshot before my updating to Chrome Beta version.
Then I found that Google realsed a new version of Chrome on 27th Jun. And my Chrome automatically updated on 30th June.That's all the reason.
I tried upgrating the chromedriver for 2.28 to 2.3, rolling back Chrome to version 64_59.0.3071.86, but it never worked. Then I found links below is really helpful.
※ Chrome 59 remote desktop chromedriver.exe saves white/blank
※ Selenium ChromeDriver makes blank screenshots
Upvotes: 4
Reputation: 72
This happened on a Windows machine for me. In the Chrome update 59 notes, one of the highlights is:
Full page screenshots - Take a screenshot of the entire page, from the top of the viewport to the bottom.
I'm assuming that something in that update broke screenshots using Jenkins. I found that rolling back to the previous version of Chrome fixed the issue for me. (Look up the build version here then download that version here).
I've also submitted a ticket here to google for this issue since I couldn't find any others. Maybe if other people comment on it, it'll get some steam.
Upvotes: 1