Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to get screenshot in headless Chrome #103

Closed
olalob opened this issue Jul 20, 2017 · 7 comments
Closed

Unable to get screenshot in headless Chrome #103

olalob opened this issue Jul 20, 2017 · 7 comments

Comments

@olalob
Copy link

olalob commented Jul 20, 2017

Hello,

I try to get a screenshot in headless Chrome (inside Docker) via

Screenshot screenshot = new AShot().shootingStrategy(ShootingStrategies.viewportPasting(10)).takeScreenshot(driver)

and on-time get the Execption:

java.lang.RuntimeException: Unexpected result for screenshot command: null
at org.openqa.selenium.remote.RemoteWebDriver.getScreenshotAs(RemoteWebDriver.java:391)
at ru.yandex.qatools.ashot.shooting.SimpleShootingStrategy.getScreenshot(SimpleShootingStrategy.java:31)
at ru.yandex.qatools.ashot.shooting.ViewportPastingDecorator.getScreenshot(ViewportPastingDecorator.java:53)
at ru.yandex.qatools.ashot.shooting.ViewportPastingDecorator.getScreenshot(ViewportPastingDecorator.java:35)
at ru.yandex.qatools.ashot.AShot.takeScreenshot(AShot.java:145)

and next time another:

java.lang.NullPointerException
at ru.yandex.qatools.ashot.shooting.ViewportPastingDecorator.getCurrentScrollY(ViewportPastingDecorator.java:80)
at ru.yandex.qatools.ashot.shooting.ViewportPastingDecorator.getScreenshot(ViewportPastingDecorator.java:54)
at ru.yandex.qatools.ashot.shooting.ViewportPastingDecorator.getScreenshot(ViewportPastingDecorator.java:35)
at ru.yandex.qatools.ashot.AShot.takeScreenshot(AShot.java:145)

but never without error :(

Maybe I must use another Strategy? Without ViewPortPasting I get no errors, but the created screenshot has only the viewable part of page without scrolling.

Could You please help me?
Thanks.

@olalob
Copy link
Author

olalob commented Jul 21, 2017

if You need my system info:

  • Ubuntu 16.04 64-bit
  • Chrome Version 59.0.3071.115 (Official Build) (64-bit)
  • Chrome Driver 2.30
  • Selenium 3.4.0
  • Java 8.0_131

@pazone
Copy link
Owner

pazone commented Jul 25, 2017

Hi, @olalob Could you please provide the docker image which is used for it?

@olalob
Copy link
Author

olalob commented Jul 31, 2017

Hello @pazone, here is my Docker file (sorry comments are formatted as headers here):

FROM ubuntu:xenial

Update & upgrade system

RUN apt-get update &&
apt-get upgrade -yq

Install required packages

RUN apt-get install -yq wget ca-certificates openjdk-8-jre-headless

Install Chrome

RUN wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - &&
sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list' &&
apt-get update &&
apt-get install -yq google-chrome-stable

Install international fonts

RUN apt-get install -yq fonts-arphic-ukai fonts-arphic-uming fonts-ipafont-mincho fonts-ipafont-gothic fonts-unfonts-core

Installation cleanup

RUN apt-get clean &&
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

Create data directory

RUN mkdir /data
WORKDIR /data

Add chrome user

RUN addgroup chrome &&
useradd -m -g chrome chrome
USER chrome

Expose Chrome remote debugging port

EXPOSE 9222

@pazone
Copy link
Owner

pazone commented Aug 23, 2017

Have you tried to use common image from here or here?
I don't see anything like xvfb in you Dockerfile. It looks like it has no graphic environment.
What's the purpose of custom docker image?

@pazone
Copy link
Owner

pazone commented Aug 23, 2017

So, the solution is to use common docker image or to add xvfb. It will help. Good luck!

@pazone pazone closed this as completed Aug 23, 2017
@olalob
Copy link
Author

olalob commented Aug 23, 2017

Thanks! I try Your suggestion.

@GrzegorzDrozd
Copy link

GrzegorzDrozd commented Aug 23, 2017 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants