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.get cannot find data targets #1501

Closed
ghost opened this issue Mar 26, 2018 · 2 comments · May be fixed by schanne/cypress#1, schanne/cypress#4 or schanne/cypress#11
Closed

cy.get cannot find data targets #1501

ghost opened this issue Mar 26, 2018 · 2 comments · May be fixed by schanne/cypress#1, schanne/cypress#4 or schanne/cypress#11

Comments

@ghost
Copy link

ghost commented Mar 26, 2018

I am running a local storybook (localhost:9001) with one Node.js application.

I am running Cypress on another Node.js application.

I am trying to get my QA people up and running by using simple tests with the provided documentation.

Embedded deep in my storybook link, I have

<span class="some__class_name" data-qa-target="a_unique_name">Blah blah blah</span>

According to the documentation, here: https://docs.cypress.io/guides/references/best-practices.html#Selecting-Elements,

I should be able to say:

   it('cy.get() - query DOM elements', function() {
      cy.visit('mylink');
      cy.get('[data-qa-target=a_unique_name]').then($elem => {
        console.log($elem);
      });
  });

But Cypress is telling me
CypressError: Timed out retrying: Expected to find element: '[data-qa-target=oas-landing-provider-name]', but never found it.

If I'm doing something wrong, it's not obvious to me. Any suggestions? There are no buttons or inputs above this span. It's literally body, section, div upon div, and some spans within the divs

@jennifer-shehane jennifer-shehane added the stage: needs information Not enough info to reproduce the issue label Mar 26, 2018
@jennifer-shehane
Copy link
Member

Your test looks written correctly from what you have provided. Have you been able to hover back over when the command runs to see if the element is actually on the page at that time?

The element may not be there yet if it is waiting for an xhr request to finish, for example.

@ghost
Copy link
Author

ghost commented Mar 26, 2018

I think the problem is actually with storybook. I'm using this blog as a reference: https://medium.com/@mtiller/testing-react-components-using-storybook-and-cypress-1689a27f55aa

And it looks like I need to grab the first storybook id, cy.get('#storybook-preview-iframe') but then I'm sort of lost after that. But I don't think that's an issue with cypress. We can close this, I would say.

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant