How can i take a screenshot if document.body is null

656 views
Skip to first unread message

sabf

unread,
Feb 1, 2012, 5:54:09 AM2/1/12
to webd...@googlegroups.com
Hello,

i would like to take a screenshot of a page that does not contain html but xml.
When i try it i got that exception:
org.openqa.selenium.WebDriverException: Could not take screenshot of current page - TypeError: document.body is null
Build info: version: '2.17.0', revision: '15540', time: '2012-01-16 16:51:46'
System info: os.name: 'Windows XP', os.arch: 'x86', os.version: '5.1', java.version: '1.6.0_27'
Driver info: driver.version: unknown
Command duration or timeout: 30.11 seconds
Build info: version: '2.17.0', revision: '15546', time: '2012-01-16 17:11:34'
System info: os.name: 'Windows 7', os.arch: 'x86', os.version: '6.1', java.version: '1.6.0_26'
Driver info: driver.version: TestBase$ScreenShotRemoteWebDriver
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:147)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:113)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:439)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:443)
at portalservices.base.TestBase$ScreenShotRemoteWebDriver.getScreenshotAs(TestBase.java:101)
at portalservices.utilities.PortalHelper.FindOrScreenshot(PortalHelper.java:95)
at portalservices.homepage.PlayerActions.Login(PlayerActions.java:325)
at portalservices.homepage.LoginTests.test_login(LoginTests.java:24)
Caused by: org.openqa.selenium.remote.ErrorHandler$UnknownServerException: Could not take screenshot of current page - TypeError: document.body is null
Build info: version: '2.17.0', revision: '15540', time: '2012-01-16 16:51:46'
System info: os.name: 'Windows XP', os.arch: 'x86', os.version: '5.1', java.version: '1.6.0_27'
Driver info: driver.version: unknown
Build info: version: '2.17.0', revision: '15546', time: '2012-01-16 17:11:34'
System info: os.name: 'Windows 7', os.arch: 'x86', os.version: '6.1', java.version: '1.6.0_26'
Driver info: driver.version: unknown
at <anonymous class>.<anonymous method>(file:///C:/DOKUME~1/testing/LOKALE~1/Temp/anonymous3842546828054785037webdriver-profile/extensions/fxdr...@googlecode.com/components/driver-component.js -> file:///C:/DOKUME~1/testing/LOKALE~1/Temp/anonymous3842546828054785037webdriver-profile/extensions/fxdr...@googlecode.com/components/firefoxDriver.js:801)
at <anonymous class>.<anonymous method>(file:///C:/DOKUME~1/testing/LOKALE~1/Temp/anonymous3842546828054785037webdriver-profile/extensions/fxdr...@googlecode.com/components/command_processor.js:10103)
at <anonymous class>.<anonymous method>(file:///C:/DOKUME~1/testing/LOKALE~1/Temp/anonymous3842546828054785037webdriver-profile/extensions/fxdr...@googlecode.com/components/command_processor.js:9983)

darrell

unread,
Feb 1, 2012, 7:06:50 AM2/1/12
to webdriver
If the built in screenshot is not working for you, you might want to
give the Java Robot a try. It will only capture the visible part of
the display. I wrote an article on doing a screen capture on
exception. The code for doing a screen capture using the Java Robot is
at the bottom of the article. You can find the article at
http://darrellgrainger.blogspot.com/2011/02/generating-screen-capture-on-exception.html.

Darrell

On Feb 1, 5:54 am, sabf <s.a....@gmx.de> wrote:
> Hello,
>
> i would like to take a screenshot of a page that does not contain html but
> xml.
> When i try it i got that exception:
> org.openqa.selenium.WebDriverException: Could not take screenshot of
> current page - TypeError: document.body is null
> Build info: version: '2.17.0', revision: '15540', time: '2012-01-16
> 16:51:46'
> System info: os.name: 'Windows XP', os.arch: 'x86', os.version: '5.1',
> java.version: '1.6.0_27'
> Driver info: driver.version: unknown
> Command duration or timeout: 30.11 seconds
> Build info: version: '2.17.0', revision: '15546', time: '2012-01-16
> 17:11:34'
> System info: os.name: 'Windows 7', os.arch: 'x86', os.version: '6.1',
> java.version: '1.6.0_26'
> Driver info: driver.version: TestBase$ScreenShotRemoteWebDriver
> at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
> at
> sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAcce ssorImpl.java:39)
> at
> sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstru ctorAccessorImpl.java:27)
> method>(file:///C:/DOKUME~1/testing/LOKALE~1/Temp/anonymous3842546828054785 037webdriver-profile/extensions/fxdri...@googlecode.com/components/driver-component.js
> ->
> file:///C:/DOKUME~1/testing/LOKALE~1/Temp/anonymous3842546828054785037webdr iver-profile/extensions/fxdri...@googlecode.com/components/firefoxDriver.js:801)
> at <anonymous class>.<anonymous
> method>(file:///C:/DOKUME~1/testing/LOKALE~1/Temp/anonymous3842546828054785 037webdriver-profile/extensions/fxdri...@googlecode.com/components/command_processor.js:10103)
> at <anonymous class>.<anonymous
> method>(file:///C:/DOKUME~1/testing/LOKALE~1/Temp/anonymous3842546828054785 037webdriver-profile/extensions/fxdri...@googlecode.com/components/command_processor.js:9983)
Reply all
Reply to author
Forward
0 new messages