Error during screenshot capture: RangeError: Index out of range | The value of "offset" is out of range.
See original GitHub issueCurrent behavior:
Executing cy.screenshot()
on large pages causes error. Stack trace:
RangeError: Index out of range
at checkInt (buffer.js:1180:11)
at Buffer.writeUInt32BE (buffer.js:1271:5)
at new Jimp (/Users/rbayliss/Library/Caches/Cypress/3.0.1/Cypress.app/Contents/Resources/app/packages/server/node_modules/jimp/index.js:137:30)
at stitchScreenshots (/Users/rbayliss/Library/Caches/Cypress/3.0.1/Cypress.app/Contents/Resources/app/packages/server/lib/screenshots.js:199:17)
at /Users/rbayliss/Library/Caches/Cypress/3.0.1/Cypress.app/Contents/Resources/app/packages/server/lib/screenshots.js:295:21
at tryCatcher (/Users/rbayliss/Library/Caches/Cypress/3.0.1/Cypress.app/Contents/Resources/app/packages/server/node_modules/bluebird/js/release/util.js:16:23)
at Promise._settlePromiseFromHandler (/Users/rbayliss/Library/Caches/Cypress/3.0.1/Cypress.app/Contents/Resources/app/packages/server/node_modules/bluebird/js/release/promise.js:510:31)
at Promise._settlePromise (/Users/rbayliss/Library/Caches/Cypress/3.0.1/Cypress.app/Contents/Resources/app/packages/server/node_modules/bluebird/js/release/promise.js:567:18)
at Promise._settlePromise0 (/Users/rbayliss/Library/Caches/Cypress/3.0.1/Cypress.app/Contents/Resources/app/packages/server/node_modules/bluebird/js/release/promise.js:612:10)
at Promise._settlePromises (/Users/rbayliss/Library/Caches/Cypress/3.0.1/Cypress.app/Contents/Resources/app/packages/server/node_modules/bluebird/js/release/promise.js:691:18)
at Async._drainQueue (/Users/rbayliss/Library/Caches/Cypress/3.0.1/Cypress.app/Contents/Resources/app/packages/server/node_modules/bluebird/js/release/async.js:133:16)
at Async._drainQueues (/Users/rbayliss/Library/Caches/Cypress/3.0.1/Cypress.app/Contents/Resources/app/packages/server/node_modules/bluebird/js/release/async.js:143:10)
at Immediate.Async.drainQueues (/Users/rbayliss/Library/Caches/Cypress/3.0.1/Cypress.app/Contents/Resources/app/packages/server/node_modules/bluebird/js/release/async.js:17:14)
at runCallback (timers.js:781:20)
at tryOnImmediate (timers.js:743:5)
at processImmediate [as _immediateCallback] (timers.js:714:5)
Desired behavior:
Screenshots are captured.
Steps to reproduce:
Call cy.screenshot()
on a page that exceeds 16,000,000 square pixels (in my case, the element is 1195px by 13518px). Reproduction test case: https://github.com/rbayliss/cypress-test-tiny/tree/index_error
Versions
Cypress package version: 3.0.1
Cypress binary version: 3.0.1
Chrome 67.0.3396.87 on OSX 10.13
Issue Analytics
- State:
- Created 5 years ago
- Reactions:14
- Comments:38 (7 by maintainers)
Top Results From Across the Web
Python IndexError: List Index Out of Range [Easy Fix] - Finxter
Key Points: To solve the “IndexError: list index out of range”, avoid do not access a non-existing list index.
Read more >index out of range - WaveMetrics
I am trying to modify a code for normalisation in igor 7. This code works was originally written in Igor4 and works fine...
Read more >Troubleshooting DBCC error 2570 in SQL Server 2005 and ...
Describes an issue where you receive DBCC Error 2570 when you use the DATA_PURITY ... Invalid or out-of-range data may have been stored...
Read more >DBDOC Online Help
Summary: GMCL provides DBDOC - a powerful documentation and support tool with live data monitoring for ABB INFI90 distributed process control systems.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
is there any update on this issue?
In my case this error was caused by the behavior of the
dom.getElementPositioning
(https://github.com/cypress-io/cypress/blob/develop/packages/driver/src/dom/coordinates.js#L27). In some cases it returns negative values between -1 and 0 infromElViewport.top
for elements that are being captured.I suppose changing https://github.com/cypress-io/cypress/blob/develop/packages/driver/src/cy/commands/screenshot.js#L235 to
y: Math.max(0, elPosition.fromElViewport.top),
will fix the problem with negative offsets.Unfortunatelly, I’m not deeply familiar with the code of cypress, so I can’t predict whether any other behavior of the system will be affected or not by this change.
Can anyone tell me where else this code is used? And is this the right place in code to fix the problem?
For now I just overwrote the
screenshot
command as a workaround and it works for me: