使用Selenium Web驱动程序和Python,我正在从一个很长的页面中捕获屏幕截图。正在获取以下错误。通常情况下,我得到任何页面的屏幕截图都没有任何问题。
[1112/102333.244:ERROR:tile_manager.cc(779)] WARNING: tile memory limits exceeded, some content may not draw
[1112/102333.296:ERROR:tile_manager.cc(779)] WARNING: tile memory limits exceeded, some content may not draw
[1112/102333.305:ERROR:tile_manager.cc(779)] WARNING: tile memory limits exceeded, some content may not draw
[1112/102337.235:ERROR:tile_manager.cc(779)] WARNING: tile memory limits exceeded, some content may not draw
[1112/102337.237:ERROR:tile_manager.cc(779)] WARNING: tile memory limits exceeded, some content may not draw
[1112/102337.241:ERROR:tile_manager.cc(779)] WARNING: tile memory limits exceeded, some content may not draw
[1112/102337.243:ERROR:tile_manager.cc(779)] WARNING: tile memory limits exceeded, some content may not draw
[1112/102357.562:ERROR:tile_manager.cc(779)] WARNING: tile memory limits exceeded, some content may not draw
[1112/102357.572:ERROR:tile_manager.cc(779)] WARNING: tile memory limits exceeded, some content may not draw
[1112/102357.585:ERROR:tile_manager.cc(779)] WARNING: tile memory limits exceeded, some content may not draw
[1112/102357.587:ERROR:tile_manager.cc(779)] WARNING: tile memory limits exceeded, some content may not draw
[1112/102358.050:ERROR:tile_manager.cc(779)] WARNING: tile memory limits exceeded, some content may not draw
[1112/102358.053:ERROR:tile_manager.cc(779)] WARNING: tile memory limits exceeded, some content may not draw
[1112/102358.058:ERROR:tile_manager.cc(779)] WARNING: tile memory limits exceeded, some content may not draw
[1112/102358.060:ERROR:tile_manager.cc(779)] WARNING: tile memory limits exceeded, some content may not draw
[1112/102429.223:ERROR:tile_manager.cc(779)] WARNING: tile memory limits exceeded, some content may not draw
[1112/102429.225:ERROR:tile_manager.cc(779)] WARNING: tile memory limits exceeded, some content may not draw
[1112/102430.153:ERROR:tile_manager.cc(779)] WARNING: tile memory limits exceeded, some content may not draw
[1112/102430.156:ERROR:tile_manager.cc(779)] WARNING: tile memory limits exceeded, some content may not draw
[1112/102430.158:ERROR:tile_manager.cc(779)] WARNING: tile memory limits exceeded, some content may not draw
[1112/102430.169:ERROR:tile_manager.cc(779)] WARNING: tile memory limits exceeded, some content may not draw
[1112/102430.170:ERROR:tile_manager.cc(779)] WARNING: tile memory limits exceeded, some content may not draw
[1112/102503.275:ERROR:tile_manager.cc(779)] WARNING: tile memory limits exceeded, some content may not draw
[1112/102503.278:ERROR:tile_manager.cc(779)] WARNING: tile memory limits exceeded, some content may not draw
Traceback (most recent call last): in get_screenshot_as_file
File "page-screen-shooter.py", line 101, in <module>
driver.save_screenshot(screen_shot_save_location + "{0}.png".format(i+1)) , in get_screenshot_as_png
File "C:Python37libsite-packagesseleniumwebdriverremotewebdriver.py", line 1055, in save_screenshot
return self.get_screenshot_as_file(filename)
File "C:Python37libsite-packagesseleniumwebdriverremotewebdriver.py", line 1032, in get_screenshot_as_file
png = self.get_screenshot_as_png()
File "C:Python37libsite-packagesseleniumwebdriverremotewebdriver.py", line 1064, in get_screenshot_as_png
return base64.b64decode(self.get_screenshot_as_base64().encode('ascii'))
File "C:Python37libsite-packagesseleniumwebdriverremotewebdriver.py", line 1074, in get_screenshot_as_base64
return self.execute(Command.SCREENSHOT)['value']
File "C:Python37libsite-packagesseleniumwebdriverremotewebdriver.py", line 321, in execute
self.error_handler.check_response(response)
File "C:Python37libsite-packagesseleniumwebdriverremoteerrorhandler.py", line 242, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.TimeoutException: Message: timeout: Timed out receiving message from renderer: 1.789
(Session info: headless chrome=78.0.3904.97)
在我的代码中,我有以下选项:
chrome_options.add_argument("--start-maximized")
chrome_options.add_argument("--headless")
chrome_options.add_argument("--log-level=3")
我删除了以下选项。
chrome_options.add_argument("--start-maximized")
然而,我得到了另一个错误:
selenium.common.exceptions.WebDriverException: Message: unknown error: unhandled inspector error: {"code":-32000,"message":"Unable to capture screenshot"}
(Session info: headless chrome=78.0.3904.97)
此错误消息。。。
[1112/102333.244:ERROR:tile_manager.cc(779)] WARNING: tile memory limits exceeded, some content may not draw
.
selenium.common.exceptions.TimeoutException: Message: timeout: Timed out receiving message from renderer: 1.789
(Session info: headless chrome=78.0.3904.97)
意味着ChromeDriver无法捕获WebBrowser的屏幕截图,即chrome=78.03904.97。
根据错误跟踪日志,尽管很明显您使用的是chrome=78.03904.97,但我们不确定ChromeDriver版本。
现在根据讨论问题1893:java.lang.AssertionError:未知错误:未处理的检查器错误错误:
unknown error: unhandled inspector error: {"code":-32000,"message":"Unable to capture screenshot"}
是在Windows上捕获屏幕截图的已知问题,在第1844期中进行了讨论:Chrome 59远程桌面chromedriver.exe保存白色/空白屏幕截图,并通过Chrome v60.0.3112.40解决
解决方案
最简单的解决方案是确保:
- 硒升级到当前版本3.141.59
- ChromeDriver更新到当前ChromeDriverv78.0级别
- Chrome更新到当前Chrome 78.0版本。(根据ChromeDriver v78.0发布说明(
Outro
问题792:AndroidEmulator-无法捕获屏幕截图