cypress-io / cypress

Fast, easy and reliable testing for anything that runs in a browser.
https://cypress.io
MIT License
47.02k stars 3.18k forks source link

Screenshot gives error of typeerror cannot read properties of undefined (reading replaceall) on windows server datacenter 2019 #26142

Closed buddydeepansh closed 1 year ago

buddydeepansh commented 1 year ago

Current behavior

I am using Cypress on Amazon workspace using Windows Server 2019 Datacentre as OS. I am trying to take screenshots of a web page and every time getting a same error on my windows that: Cannot read properties of undefined (reading 'replaceAll')     at Object.toPosix (https://www.iciciprulife.com/__cypress/runner/cypress_runner.js:159314:56) and  Uncaught TypeError: Cannot read properties of null (reading 'getBoundingClientRect')     at getViewPercentage (:8:39)

Although my screenshots are getting saved in the screenshot folder but it fails the script execution after taking screenshot.

image image image

Desired behavior

I just want to save my screenshots normally without getting any errors and the script should execute succcessfullyafter taking and saving the screenshots.

Test code to reproduce

describe("example to-do app", () => { it("Signature Testing", () => { cy.viewport(1336, 720) cy.visit("https://www.iciciprulife.com/ulip-plans/unit-linked-insurance-plans/icici-pru-signature-ulip-calculator.html") cy.wait(10000) cy.screenshot() cy.on("uncaught:exception", (err, runnable) => { console.log(err) return false }) }) })

Cypress Version

12.8.1

Node version

16.14.0

Operating System

Windows Server 2019 datacenter

Debug Logs

No response

Other

No response

lmiller1990 commented 1 year ago

Hi! I was able to run the project on my own environment (linux). I was able to take the screenshot, though, despite some errors in the console. did not see replaceAll. I suspect it comes from here.

export const toPosix = (file: string) => {
  return Cypress.config('platform') === 'win32'
    ? file.replaceAll('\\', '/')
    : file

So file must be undefined. I wonder what's causing this to throw in the first place. I will investigate.

Do you see something similar when running on an alternative windows machine, or do you think it's specific to your windows server 2019 environment?

example to-do app -- Signature Testing

lmiller1990 commented 1 year ago

Happy to reopen once we've got more information to continue debugging. Until then, I'll close this, since I don't see any actionable work in Cypress relating to this issue.