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

WebDriver:TakeScreenshot returns empty string on SVG document #1278

Open
RazrFalcon opened this issue May 21, 2018 · 3 comments
Open

WebDriver:TakeScreenshot returns empty string on SVG document #1278

RazrFalcon opened this issue May 21, 2018 · 3 comments

Comments

@RazrFalcon
Copy link

RazrFalcon commented May 21, 2018

System

  • Version: 0.20.0
  • Platform: Arch Linux
  • Firefox: 60.0.1 (64-bit)
  • Selenium: Version: 3.12.0-1

Testcase

#!/usr/bin/env python3.6

from selenium.webdriver import Firefox
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.firefox.options import Options
from selenium.webdriver.support import expected_conditions as expected
from selenium.webdriver.support.wait import WebDriverWait

if __name__ == "__main__":
    options = Options()
    options.add_argument('-headless')
    driver = Firefox(executable_path='geckodriver', firefox_options=options)
    wait = WebDriverWait(driver, timeout=10)
    driver.get('https://upload.wikimedia.org/wikipedia/commons/0/02/SVG_logo.svg')
    driver.save_screenshot('screenshot.png')
    driver.quit()

This will create a zero sized file.

Stacktrace

1526910879710	geckodriver	INFO	geckodriver 0.20.0
1526910879715	geckodriver	INFO	Listening on 127.0.0.1:35109
1526910880750	mozrunner::runner	INFO	Running command: "/usr/bin/firefox" "-marionette" "-headless" "-profile" "/tmp/rust_mozprofile.E7MT0rgLQ95V"
*** You are running in headless mode.
1526910881934	Marionette	INFO	Listening on port 37957
1526910881958	Marionette	WARN	TLS certificate errors will be ignored for this session
1526910882363	addons.xpi	WARN	Exception running bootstrap method shutdown on activity-stream@mozilla.org: [Exception... "Component returned failure code: 0x80004005 (NS_ERROR_FAILURE) [nsIObserverService.removeObserver]"  nsresult: "0x80004005 (NS_ERROR_FAILURE)"  location: "JS frame :: resource://activity-stream/lib/SnippetsFeed.jsm :: uninit :: line 185"  data: no] Stack trace: uninit()@resource://activity-stream/lib/SnippetsFeed.jsm:185
onAction()@resource://activity-stream/lib/SnippetsFeed.jsm:201
_middleware/</<()@resource://activity-stream/lib/Store.jsm:49
Store/this[method]()@resource://activity-stream/lib/Store.jsm:28
uninit()@resource://activity-stream/lib/Store.jsm:151
uninit()@resource://activity-stream/lib/ActivityStream.jsm:300
uninit()@resource://gre/modules/addons/XPIProvider.jsm -> jar:file:///usr/lib/firefox/browser/features/activity-stream@mozilla.org.xpi!/bootstrap.js:73
shutdown()@resource://gre/modules/addons/XPIProvider.jsm -> jar:file:///usr/lib/firefox/browser/features/activity-stream@mozilla.org.xpi!/bootstrap.js:169
callBootstrapMethod()@resource://gre/modules/addons/XPIProvider.jsm:4436
observe()@resource://gre/modules/addons/XPIProvider.jsm:2287
GeckoDriver.prototype.quit()@driver.js:3300
despatch()@server.js:293
execute()@server.js:267
onPacket/<()@server.js:242
onPacket()@server.js:241
_onJSONObjectReady/<()@transport.js:500
*** UTM:SVC TimerManager:registerTimer called after profile-before-change notification. Ignoring timer registration for id: telemetry_modules_ping
1526910882690	geckodriver::marionette	ERROR	Failed to stop browser process

Trace-level log

1526914779111	geckodriver	INFO	geckodriver 0.20.0
1526914779116	geckodriver	INFO	Listening on 127.0.0.1:60793
1526914780161	mozrunner::runner	INFO	Running command: "/usr/bin/firefox" "-marionette" "-headless" "-profile" "/tmp/rust_mozprofile.1WBzhC080OJy"
1526914780162	geckodriver::marionette	TRACE	  connection attempt 0/600
*** You are running in headless mode.
1526914780262	geckodriver::marionette	TRACE	  connection attempt 1/600
1526914780362	geckodriver::marionette	TRACE	  connection attempt 2/600
1526914780449	Marionette	DEBUG	Received observer notification profile-after-change
1526914780463	geckodriver::marionette	TRACE	  connection attempt 3/600
1526914780503	Marionette	DEBUG	Received observer notification command-line-startup
1526914780503	Marionette	DEBUG	Received observer notification nsPref:changed
1526914780563	geckodriver::marionette	TRACE	  connection attempt 4/600
1526914780663	geckodriver::marionette	TRACE	  connection attempt 5/600
1526914780763	geckodriver::marionette	TRACE	  connection attempt 6/600
1526914780864	geckodriver::marionette	TRACE	  connection attempt 7/600
1526914780964	geckodriver::marionette	TRACE	  connection attempt 8/600
1526914781064	geckodriver::marionette	TRACE	  connection attempt 9/600
1526914781155	Marionette	DEBUG	Received observer notification sessionstore-windows-restored
1526914781165	geckodriver::marionette	TRACE	  connection attempt 10/600
1526914781265	geckodriver::marionette	TRACE	  connection attempt 11/600
1526914781268	Marionette	DEBUG	Setting recommended pref toolkit.cosmeticAnimations.enabled to false
1526914781268	Marionette	DEBUG	Setting recommended pref datareporting.policy.dataSubmissionPolicyAccepted to false
1526914781268	Marionette	DEBUG	Setting recommended pref extensions.shield-recipe-client.api_url to 
1526914781304	Marionette	DEBUG	New connections are accepted
1526914781305	Marionette	INFO	Listening on port 40037
1526914781365	geckodriver::marionette	DEBUG	Connected to Marionette on localhost:40037
1526914781367	Marionette	DEBUG	Accepted connection 0 from 127.0.0.1:43478
1526914781368	geckodriver::marionette	TRACE	<- {"applicationType":"gecko","marionetteProtocol":3}
1526914781368	geckodriver::marionette	TRACE	-> 163:[0,1,"newSession",{"acceptInsecureCerts":true,"browserName":"firefox","capabilities":{"desiredCapabilities":{"acceptInsecureCerts":true,"browserName":"firefox"}}}]
1526914781369	Marionette	TRACE	0 -> [0,1,"newSession",{"acceptInsecureCerts":true,"browserName":"firefox","capabilities":{"desiredCapabilities":{"acceptInsecureCerts":true,"browserName":"firefox"}}}]
1526914781370	Marionette	WARN	TLS certificate errors will be ignored for this session
1526914781399	Marionette	DEBUG	Register listener.js for window 2147483649
1526914781404	Marionette	TRACE	0 <- [1,1,null,{"sessionId":"01c481ed-ec83-4a2e-88f7-42f1f9a39d51","capabilities":{"browserName":"firefox","browserVersion":"60.0. ... 1,"moz:profile":"/tmp/rust_mozprofile.1WBzhC080OJy","moz:useNonSpecCompliantPointerOrigin":false,"moz:webdriverClick":true}}]
1526914781405	geckodriver::marionette	TRACE	<- [1,1,null,{"sessionId":"01c481ed-ec83-4a2e-88f7-42f1f9a39d51","capabilities":{"browserName":"firefox","browserVersion":"60.0.1","platformName":"linux","platformVersion":"4.16.9-1-ARCH","pageLoadStrategy":"normal","acceptInsecureCerts":true,"timeouts":{"implicit":0,"pageLoad":300000,"script":30000},"rotatable":false,"moz:accessibilityChecks":false,"moz:headless":true,"moz:processID":14511,"moz:profile":"/tmp/rust_mozprofile.1WBzhC080OJy","moz:useNonSpecCompliantPointerOrigin":false,"moz:webdriverClick":true}}]
1526914781405	webdriver::server	DEBUG	<- 200 OK {"value": {"sessionId":"01c481ed-ec83-4a2e-88f7-42f1f9a39d51","capabilities":{"acceptInsecureCerts":true,"browserName":"firefox","browserVersion":"60.0.1","moz:accessibilityChecks":false,"moz:headless":true,"moz:processID":14511,"moz:profile":"/tmp/rust_mozprofile.1WBzhC080OJy","moz:useNonSpecCompliantPointerOrigin":false,"moz:webdriverClick":true,"pageLoadStrategy":"normal","platformName":"linux","platformVersion":"4.16.9-1-ARCH","rotatable":false,"timeouts":{"implicit":0,"pageLoad":300000,"script":30000}}}}
1526914781406	webdriver::server	DEBUG	-> POST /session/01c481ed-ec83-4a2e-88f7-42f1f9a39d51/url {"url": "https://upload.wikimedia.org/wikipedia/commons/0/02/SVG_logo.svg"}
1526914781406	geckodriver::marionette	TRACE	-> 86:[0,2,"get",{"url":"https://upload.wikimedia.org/wikipedia/commons/0/02/SVG_logo.svg"}]
1526914781417	Marionette	TRACE	0 -> [0,2,"get",{"url":"https://upload.wikimedia.org/wikipedia/commons/0/02/SVG_logo.svg"}]
1526914781425	Marionette	DEBUG	Received DOM event beforeunload for about:blank
1526914781621	Marionette	DEBUG	Received DOM event pagehide for about:blank
1526914781626	Marionette	DEBUG	Received DOM event DOMContentLoaded for https://upload.wikimedia.org/wikipedia/commons/0/02/SVG_logo.svg
1526914781654	Marionette	DEBUG	Received DOM event pageshow for https://upload.wikimedia.org/wikipedia/commons/0/02/SVG_logo.svg
1526914781659	Marionette	TRACE	0 <- [1,2,null,{}]
1526914781663	geckodriver::marionette	TRACE	<- [1,2,null,{}]
1526914781663	webdriver::server	DEBUG	<- 200 OK {"value": {}}
1526914781663	webdriver::server	DEBUG	-> GET /session/01c481ed-ec83-4a2e-88f7-42f1f9a39d51/screenshot 
1526914781664	geckodriver::marionette	TRACE	-> 63:[0,3,"takeScreenshot",{"full":false,"highlights":[],"id":null}]
1526914781664	Marionette	TRACE	0 -> [0,3,"takeScreenshot",{"full":false,"highlights":[],"id":null}]
1526914781667	Marionette	TRACE	0 <- [1,3,null,{"value":""}]
1526914781667	geckodriver::marionette	TRACE	<- [1,3,null,{"value":""}]
1526914781667	webdriver::server	DEBUG	<- 200 OK {"value":""}
1526914781668	webdriver::server	DEBUG	-> DELETE /session/01c481ed-ec83-4a2e-88f7-42f1f9a39d51 
1526914781668	geckodriver::marionette	TRACE	-> 37:[0,4,"quit",{"flags":["eForceQuit"]}]
1526914781669	Marionette	TRACE	0 -> [0,4,"quit",{"flags":["eForceQuit"]}]
1526914781669	Marionette	DEBUG	New connections will no longer be accepted
1526914781685	addons.xpi	WARN	Exception running bootstrap method shutdown on activity-stream@mozilla.org: [Exception... "Component returned failure code: 0x80004005 (NS_ERROR_FAILURE) [nsIObserverService.removeObserver]"  nsresult: "0x80004005 (NS_ERROR_FAILURE)"  location: "JS frame :: resource://activity-stream/lib/SnippetsFeed.jsm :: uninit :: line 185"  data: no] Stack trace: uninit()@resource://activity-stream/lib/SnippetsFeed.jsm:185
onAction()@resource://activity-stream/lib/SnippetsFeed.jsm:201
_middleware/</<()@resource://activity-stream/lib/Store.jsm:49
Store/this[method]()@resource://activity-stream/lib/Store.jsm:28
uninit()@resource://activity-stream/lib/Store.jsm:151
uninit()@resource://activity-stream/lib/ActivityStream.jsm:300
uninit()@resource://gre/modules/addons/XPIProvider.jsm -> jar:file:///usr/lib/firefox/browser/features/activity-stream@mozilla.org.xpi!/bootstrap.js:73
shutdown()@resource://gre/modules/addons/XPIProvider.jsm -> jar:file:///usr/lib/firefox/browser/features/activity-stream@mozilla.org.xpi!/bootstrap.js:169
callBootstrapMethod()@resource://gre/modules/addons/XPIProvider.jsm:4436
observe()@resource://gre/modules/addons/XPIProvider.jsm:2287
GeckoDriver.prototype.quit()@driver.js:3300
despatch()@server.js:293
execute()@server.js:267
onPacket/<()@server.js:242
onPacket()@server.js:241
_onJSONObjectReady/<()@transport.js:500
1526914781700	Marionette	TRACE	0 <- [1,4,null,{"cause":"shutdown"}]
1526914781712	geckodriver::marionette	TRACE	<- [1,4,null,{"cause":"shutdown"}]
1526914781712	webdriver::server	DEBUG	Deleting session
1526914781712	geckodriver::marionette	TRACE	-> 37:[0,5,"quit",{"flags":["eForceQuit"]}]
1526914781713	Marionette	TRACE	0 -> [0,5,"quit",{"flags":["eForceQuit"]}]
1526914781714	Marionette	TRACE	0 <- [1,5,{"error":"invalid session id","message":"","stacktrace":"WebDriverError@chrome://marionette/content/error.js:178:5\nInva ... et@chrome://marionette/content/server.js:241:8\n_onJSONObjectReady/<@chrome://marionette/content/transport.js:500:9\n"},null]
1526914781714	geckodriver::marionette	TRACE	<- [1,5,{"error":"invalid session id","message":"","stacktrace":"WebDriverError@chrome://marionette/content/error.js:178:5\nInvalidSessionIDError@chrome://marionette/content/error.js:347:5\nassert.that/<@chrome://marionette/content/assert.js:405:13\nassert.session@chrome://marionette/content/assert.js:79:3\ndespatch@chrome://marionette/content/server.js:290:7\nexecute@chrome://marionette/content/server.js:267:11\nonPacket/<@chrome://marionette/content/server.js:242:15\nonPacket@chrome://marionette/content/server.js:241:8\n_onJSONObjectReady/<@chrome://marionette/content/transport.js:500:9\n"},null]
1526914781720	Marionette	DEBUG	Closed connection 0
*** UTM:SVC TimerManager:registerTimer called after profile-before-change notification. Ignoring timer registration for id: telemetry_modules_ping
1526914781787	Marionette	DEBUG	Received observer notification xpcom-will-shutdown
1526914781787	Marionette	DEBUG	Resetting recommended pref toolkit.cosmeticAnimations.enabled
1526914781788	Marionette	DEBUG	Resetting recommended pref datareporting.policy.dataSubmissionPolicyAccepted
1526914781788	Marionette	DEBUG	Resetting recommended pref extensions.shield-recipe-client.api_url
1526914782014	geckodriver::marionette	ERROR	Failed to stop browser process
1526914782019	webdriver::server	DEBUG	<- 200 OK {"value": {}}

@andreastt
Copy link
Contributor

That stacktrace does actually not appear to originate from geckodriver, but from Activity Stream. It should not be anything to worry about, and you may see that it has disappeared in a more recent nightly build of Firefox. You can also see in the trace-level log that it is not associated with the takeScreenshot command, but with quit.

That said, the return value from takeScreenshot is an empty string, which we would not expect for https://upload.wikimedia.org/wikipedia/commons/0/02/SVG_logo.svg. I expect there is an issue somewhere dealing with the correct document type, since the document is an XML file.

@andreastt andreastt changed the title Can't save a screenshot of the SVG file WebDriver:TakeScreenshot returns empty string on SVG document May 21, 2018
@whimboo
Copy link
Collaborator

whimboo commented May 24, 2018

@andreastt you added the marionette label, can you please also file an appropriate bug so this bug isn't get lost? Thanks.

@whimboo
Copy link
Collaborator

whimboo commented Jun 29, 2018

This has been filed as https://bugzilla.mozilla.org/show_bug.cgi?id=1471262.

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

No branches or pull requests

3 participants