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

cy.visit() Error - DOM Element id Attribute Set to jquery #6193

Closed
kenchandev opened this issue Jan 18, 2020 · 4 comments · Fixed by #7249
Closed

cy.visit() Error - DOM Element id Attribute Set to jquery #6193

kenchandev opened this issue Jan 18, 2020 · 4 comments · Fixed by #7249

Comments

@kenchandev
Copy link

@kenchandev kenchandev commented Jan 18, 2020

Current behavior:

Given a static webpage with zero JavaScript present (no jQuery library), if there exists a DOM element with an id attribute set to jquery (for example, <p id="jquery">jQuery</p>), then the cy.visit() method throws a TypeError: TypeError: item.first is not a function.

Debug Logs:

cypress_runner.js:159529 TypeError: item.first is not a function

Because this error occurred during a 'before each' hook we are skipping the remaining tests in the current suite: 'homepage'
    at Object.unwrapFirst (http://localhost:5000/__cypress/runner/cypress_runner.js:86108:19)
    at http://localhost:5000/__cypress/runner/cypress_runner.js:80941:33
From previous event:
    at runCommand (http://localhost:5000/__cypress/runner/cypress_runner.js:80933:8)
    at next (http://localhost:5000/__cypress/runner/cypress_runner.js:81014:14)
From previous event:
    at http://localhost:5000/__cypress/runner/cypress_runner.js:81055:37
From previous event:
    at run (http://localhost:5000/__cypress/runner/cypress_runner.js:81048:19)
    at Object.cy.<computed> [as visit] (http://localhost:5000/__cypress/runner/cypress_runner.js:81457:11)
    at Context.runnable.fn (http://localhost:5000/__cypress/runner/cypress_runner.js:81699:24)
    at callFn (http://localhost:5000/__cypress/runner/cypress_runner.js:30929:21)
    at Hook.../driver/node_modules/mocha/lib/runnable.js.Runnable.run (http://localhost:5000/__cypress/runner/cypress_runner.js:30922:7)
    at http://localhost:5000/__cypress/runner/cypress_runner.js:84876:28
From previous event:
    at Object.onRunnableRun (http://localhost:5000/__cypress/runner/cypress_runner.js:84864:20)
    at $Cypress.action (http://localhost:5000/__cypress/runner/cypress_runner.js:78026:61)
    at Hook.Runnable.run (http://localhost:5000/__cypress/runner/cypress_runner.js:83558:13)
    at next (http://localhost:5000/__cypress/runner/cypress_runner.js:31272:10)
    at http://localhost:5000/__cypress/runner/cypress_runner.js:31294:5
    at timeslice (http://localhost:5000/__cypress/runner/cypress_runner.js:26362:27)
logError @ cypress_runner.js:159529

Added a breakpoint to view the object that's considered a "jQuery object:"

Desired behavior:

In a previous issue, this type of error was thrown when an older version of jQuery was found on the webpage being tested: #2927. According to the issue thread, it was resolved in Cypress v3.2.0.

I'd expect that a webpage with zero JavaScript present shouldn't encounter this error.

Test code to reproduce

https://github.com/kenchandev/cypress-bug-reduced-test-case

The README.md file will contain directions on how to quickly reproduce this bug.

Versions

Cypress: v3.8.2
Operating System: Mac OS X
Browser: Cypress Test Runner's Default Browser

@jennifer-shehane
Copy link
Member

@jennifer-shehane jennifer-shehane commented Jan 22, 2020

This is very weird. Reproducible example below.

index.html

<!DOCTYPE html>
<body>
  <p id="jquery">jQuery</p>
</body>
</html>

spec.js

it('should find the jQuery text', () => {
  cy.visit('index.html')
  cy.contains('jQuery').should('exist')
})

Screen Shot 2020-01-22 at 1 37 52 PM

Code

This is being thrown from this line of code:

https://github.com/cypress-io/cypress/blob/develop/packages/driver/src/cypress/utils.coffee#L67

With id="jquery"

Screen Shot 2020-01-22 at 1 44 15 PM

Without id="jquery"

Screen Shot 2020-01-22 at 1 44 48 PM

@cypress-bot cypress-bot bot added the stage: ready for work label Jan 22, 2020
@protyay
Copy link

@protyay protyay commented Jan 23, 2020

Hello, @jennifer-shehane , can i work on this issue ?

@panzarino panzarino linked a pull request May 6, 2020 that will close this issue
2 tasks
@cypress-bot cypress-bot bot added stage: needs review stage: work in progress and removed stage: ready for work stage: needs review stage: work in progress labels May 7, 2020
@cypress-bot cypress-bot bot added the stage: pending release label May 17, 2020
@cypress-bot
Copy link

@cypress-bot cypress-bot bot commented May 17, 2020

The code for this is done in cypress-io/cypress#7249, but has yet to be released.
We'll update this issue and reference the changelog when it's released.

@cypress-bot cypress-bot bot removed the stage: needs review label May 17, 2020
@cypress-bot
Copy link

@cypress-bot cypress-bot bot commented May 20, 2020

Released in 4.6.0.

This comment thread has been locked. If you are still experiencing this issue after upgrading to
Cypress v4.6.0, please open a new issue.

@cypress-bot cypress-bot bot removed the stage: pending release label May 20, 2020
@cypress-bot cypress-bot bot locked as resolved and limited conversation to collaborators May 20, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants