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

Open
kenchandev opened this issue Jan 18, 2020 · 2 comments
Open

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

kenchandev opened this issue Jan 18, 2020 · 2 comments

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

This comment has been minimized.

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

@protyay

This comment has been minimized.

Copy link

@protyay protyay commented Jan 23, 2020

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

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

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.