https://cypress.io logo
Join Discord
Powered by
# i-need-help
  • Cypress commands not running in console
    s

    salmon-agent-14439

    01/17/2023, 10:54 PM
    Hi, I'm debugging an issue, where
    cy.window()
    seems to not be returning its promise, and causing tests to timeout. Upon further investigation using Cypress 7.7.0 (an older version because the newer ones significantly increase test times), I discovered that in the Electron window's console (after the tests pass),
    cy
    commands do not get run at all sometimes! See the attached screenshot -
    test
    got incremented only once, and from then on it wouldn't increment again. And this applies to any further
    cy.
    commands - none of them work anymore (for example,
    cy.get('#foo').click()
    wouldn't work). Anyone knows what's going on?
    p
    • 2
    • 1
  • Component Testing (Nuxt 3)
    l

    lively-match-61863

    01/18/2023, 5:38 AM
    Hello, Is it possible to do component testing in Nuxt 3 using Cypress? Any resources please? Thank you
    w
    • 2
    • 1
  • Cypress task with only console.log fails with timeout error
    a

    aloof-petabyte-2674

    01/18/2023, 7:48 AM
    Hi everyone. I have a cypress task for logging data to console and I've noticed that from time to time it fails on CI with timeout err. How to debug such problem?
    Copy code
    cy.task('log') timed out after waiting 60000ms
    Copy code
    on('task', {
        generateOTP: require('cypress-otp'),
        log(msg) {
          console.log(`[${new Date().toLocaleTimeString()}]: ${msg}`);
          return null;
        },
    m
    • 2
    • 2
  • Webpack Compilation Error
    h

    helpful-truck-53930

    01/18/2023, 8:31 AM
    Hello everyone, Currently i have a problem with a Webpack in cypress 12.3.0. If i try to start my test cypress can't find the module. I tried to install Ntlm in the past. I will attach a screenshot of this error. What's the next steps?
  • I want to get all div where they must contain a label and input, how can I do this?
    p

    purple-afternoon-2408

    01/18/2023, 10:25 AM
    I tried
    filter
    as per https://docs.cypress.io/api/commands/filter but it seems that it's not doing what I need. Here is example code:
    Copy code
    cy.get('div').filter('label').filter('input');
    I expect the statement above to yeld those
    div
    elements. Considering that
    filter
    is not helping, is there alternative?
    g
    • 2
    • 6
  • how configure chrome as defult browser in ci
    l

    lively-balloon-98986

    01/18/2023, 10:52 AM
    how configure chrome as defult browser in ci
    t
    • 2
    • 3
  • unable to access variable outside of each() method
    a

    aloof-quill-23445

    01/18/2023, 11:01 AM
    do{ var years = [] cy.get('tbody>tr>td>span').each(($ele,i)=>{ // const years = (Cypress._.map($ele,(list)=>list.innerText)).join(',') years.push($ele.text()) }).then(()=>{ if(years.includes(spDate[2])){ selectyear() selectmonth() selectdate() }else{ if(years[0]>spDate[2]){ cy.log('click back') cy.get(':nth-child(1) > .chevron').click({force:true}) }else{cy.log('click forward') cy.get(':nth-child(3) > .chevron').click() } } }) // cy.then(()=>{ // return years // }) }while(years.includes(spDate[2])) years in while condition is empty Can anyone please help me out
    g
    • 2
    • 4
  • SyntaxError only when website is visited with Cypress
    e

    echoing-napkin-22534

    01/18/2023, 11:09 AM
    I am testing a website that loads a lot of third-party JavaScript. During page load one of those scripts leads to a
    Uncaught SyntaxError: Unexpected token '.'
    or
    Uncaught SyntaxError: invalid property id .
    (dependending on the browser Cypress uses). But this only happens if the website is visited with Cypress. Using the website with a standard end-user browser shows no problems. Does Cypress somehow change the JavaScript it loads in a way that could lead to such a SyntaxError? I have absolutely no clue how to debug this issue. The error position points to somewhere within the minified third-party source which is of no help. And, again, the source loads fine in other browsers. Any hints for how to debug this problem? Thanks!
    t
    • 2
    • 8
  • Cypress keeps loading while trying to open
    b

    breezy-pilot-11152

    01/18/2023, 11:26 AM
    I am a first time user of cypress. I installed it and now trying to run my first test case but when I try
    npx cypress open
    it just opens cypress and keeps loading. Not sure if I configured it incorrectly. Can someone help?
    w
    • 2
    • 1
  • What is the best approach with Amazon Cognito
    p

    prehistoric-whale-53486

    01/18/2023, 1:25 PM
    On the project I am on we have Amazon Cognito to handle users and logins. At the moment we use the official recipe to log-in and it works well. But the team lead wants us to change it. The argument that is circulated is that we want to test the Frontend and not rely on the backend/cognito to be able to test the frontend. Does this make sense to people that had expirience with cognito? Or would it be a waste of time for no real benefit? We in theory know how to "skip the login", but I want to know is it useful to do that at all.
    e
    e
    • 3
    • 2
  • How to use CI/CD w/ frontend and backend in separate repos?
    f

    faint-journalist-59022

    01/18/2023, 2:17 PM
    hi, i hope this is the right spot for this discussion. as the title says i have a react frontend and a rails backend that are in separate repos and i'd like to have some automation for the testing. currently i have a pre-commit hook running locally which requires both app pieces to be running locally. is there a way to have this work w/github actions? most examples i see are standalone apps so kinda unsure where to go from here thanks!
    g
    b
    e
    • 4
    • 4
  • How to automatically log or debug the results of cy.visit?
    r

    ripe-vr-94086

    01/18/2023, 3:21 PM
    Hey folks, I can see from https://docs.cypress.io/api/commands/visit#Command-Log that you can manually click on a visit command to see the redirects, set cookies, etc. Is there a way to force this to be logged automatically (without having to click on
    visit
    )? We're currently seeing some intermittent issues on navigating to our website and our backend folks have asked us to log the results of that command (to check the cookies, etc). I'm also currently using https://github.com/archfz/cypress-terminal-report to log any messages from the browser console to our Cypress runs as well, which means if I can get the information on the browser console automatically, our Cypress CI runs will be able to log that info. Thanks in advance!
    t
    e
    • 3
    • 12
  • How can I drop organizations from my account?
    f

    flat-rocket-60743

    01/18/2023, 5:53 PM
    I set my self up on cypress with 2 organizations, and I need to drop the organizations and just keep my personal account. Can someone help me please?
    b
    • 2
    • 11
  • await cy.task?
    m

    millions-pizza-46232

    01/18/2023, 7:09 PM
    I am attempting to run an async node script as a Cypress Task. I have it all done, I just don't know how to get Cypress itself to wait for the task to be complete.
    await cy.task()
    does not seem to work, but it hopefully explains what I am trying to do. Does anyone have any ideas on how to do this? Thank you 🙂
    g
    e
    • 3
    • 14
  • How can I select react dropdown options most effectively?
    r

    refined-rose-98234

    01/18/2023, 8:12 PM
    Hi, looking for some specific help on an issue I haven't been able to solve by googling. I will try my best to provide the best context I can and appreciate any feedback / help I can get. I am probably missing something totally obvious but have spent too much time and could use some advice on best practice here because our app uses this functionality widely. I am trying to select an option from a dropdown within a modal (in this example, the value 'hdp') in an app that is built in React and I can't figure out a couple of things 1. I can't find a way to add a data-test-id to dropdown options 2. there doesn't seem to be a way to identify these options via classes, ids, labels etc. because they are dynamic (e.g., 'react-select-3-option-0' which is very flaky) 3. I have tried selecting it with something like:
    cy.get("div").contains("hdp") and it seems like it finds it but when I try to add '.click()' even with force:true
    and I get this result (screenshot 1) Here's what the structure of the code looks like (screenshot 2) I have tried
    .should
    statements with various commands about containing text, adding
    cy.wait
    before the get to make sure it's there but it seems like it's trying to find elements from the root document instead of the modal so any advice would be appreciated 🙂 thanks, new to Cypress.
    b
    b
    +2
    • 5
    • 8
  • [vue component] useRoute() is undefined
    p

    prehistoric-lion-87710

    01/18/2023, 8:15 PM
    I have this vue3 component that crashes because of these lines
    Copy code
    javascript
    const route = useRoute();
    if (route.params.modelId) {
    Cannot read properties of undefined (reading 'params')
    what can I do ? useRoute() shouldn’t be undefined, should it ?
  • Add custom data to test response
    n

    narrow-jewelry-82430

    01/19/2023, 12:35 AM
    I'm running Cypress as a Node module as described here: https://docs.cypress.io/guides/guides/module-api I have a trouble with returning an actual value that was found on the website. This is my node file:
    Copy code
    js
    const cypress = require('cypress');
    
    function runCypressTest() {
      return cypress
      .run({
        headed: true,
        env: {
          url: 'my_url',
        },
        spec: './cypress/e2e/test.cy.js'
      })
      .then((results) => {
        return results
      })
      .catch((err) => {
        console.error(err)
      })
    }
    
    runCypressTest().then((results) => {
      console.log(results); // I need the element conents here
    });
    And this is my spec:
    Copy code
    js
    describe('has class', () => {
      it('passes', () => {
        cy.visit(Cypress.env('url'))
        cy.get(".my_class").then(function($elem) {
          cy.log($elem.text())
     })
      })
    })
    So currently I'm logging out the text of the element with
    cy.log($elem.text())
    and the caller receives standard Cypress result of the test. I would need to somehow pass the value of an element back to the node function. How can I do this? Is it possible to archive without using files to transfer the data between test and node function?
    e
    g
    • 3
    • 2
  • Clearing web data after each test
    c

    chilly-magician-65885

    01/19/2023, 1:52 AM
    I have multiple tests for my page, i only have one authentication block-beforeAll. But after the test completes all site data is cleared, and again need to use authentication and the page loading which is very time consuming. Need a solution to prevent clearing of page data
    b
    c
    +2
    • 5
    • 7
  • Bypass authentication for my page alternative to entering credentials
    c

    chilly-magician-65885

    01/19/2023, 1:58 AM
    Alternative to using my credentials for my website for testng. Don't want other users who test the page to use my credentials
    b
    m
    • 3
    • 3
  • crossOriginIsolated for SharedArrayBuffer testing
    a

    ancient-sundown-28754

    01/19/2023, 3:17 AM
    Our medical imaging viewer app (https://v3-demo.ohif.org/) make use of SharedArrayBuffer, which requires us to add the following headers in our webpack server and in production
    Copy code
    headers: {
        'Cross-Origin-Embedder-Policy': 'require-corp',
        'Cross-Origin-Opener-Policy': 'same-origin',
     },
    Which works great and we test the browser by checking the
    window.crossOriginIsolated
    which after setting the headers becomes true (https://developer.mozilla.org/en-US/docs/Web/API/crossOriginIsolated) Now I want to use cypress to test some functionality around the SharedArrayBuffer, but could not find a place to set these headers. I disabled the
    chromeWebSecurity
    but that didn't help either I appreciate any help PS: I found this comment, but not sure where to add the headers: https://github.com/cypress-io/cypress/issues/19912#issuecomment-1024276051
  • Dynamic subdomains
    a

    average-yak-99766

    01/19/2023, 3:57 AM
    Just started with Cypress! I have a React TS project w/ Vite. Users visit the root ie.
    localhost:3000
    which lets them enter their organisation subdomain, ie.
    test-org
    . When they submit the form and the API responds with the found organisation, we use
    window.location.host = ${data.subdomain}.${import.meta.env.VITE_REACT_STATIC_HOSTNAME}
    which forces a page refresh, and thus they are at their given organisation which takes them to the login page ie.
    http://test-org.localhost:3000/login
    The issue I'm experiencing is that when the
    window.location.host
    occurs Cypress states
    test-org.localhost didn't return any data
    and eventually times out.
    VITE_REACT_STATIC_HOSTNAME
    =
    localhost:3000
    basic e2e test:
    Copy code
    describe('E2E : Subdomain Page', () => {
      it('should find the subdomain and direct user to the organisations login page', () => {
        cy.visit('/')
    
        // Input test organisation
        const input = cy.get('input[type="text"]').should('have.attr', 'placeholder', 'domain')
        input.type('test-org')
    
        // Submit for
        cy.get('button').contains('Continue').click()
      })
    })
    config:
    Copy code
    export default defineConfig({
      hosts: {
        '*.localhost': '127.0.0.1',
      },
      e2e: {
        baseUrl: 'http://localhost:3000',
      },
    })
    Any help to why this would be happening would be appreciated, thank you! Have found a similar issue https://github.com/cypress-io/cypress/issues/18881 but didn't seem to work.
    • 1
    • 1
  • Can you loop through each it test?
    a

    adamant-agency-73481

    01/19/2023, 7:52 AM
    When you run the test, you want to go like a -> b -> c, then go back to b and run b -> d -> e like this? This is how to save the state of b and return
    p
    g
    • 3
    • 2
  • Hide credentials in allure report with Cypress?
    s

    straight-microphone-66008

    01/19/2023, 9:26 AM
    Hello guys, On my Cypress tests when I type the password I used the option {log:false} to hide the password so it wont show on the cypress runner, but on my allure report it still does show. any of you managed to hide the credentials on the allure report too?
    d
    p
    t
    • 4
    • 8
  • Possible to import tasks into the cypress.config.ts e2e { }?
    s

    stocky-insurance-27750

    01/19/2023, 9:41 AM
    I've got a few tasks in the
    e2e: { setupNodeEvents() { } }
    and I'm wondering if it's possible put them in their own file(s) and then have an import in the setupNodeEvents...to keep it looking clean and tidy/easier to read?
    s
    • 2
    • 7
  • How can we resolve firefox cross origin issue when new window (use stub) is open with diff. domain.
    q

    quaint-dusk-70197

    01/19/2023, 1:38 PM
    cy.origin("domain1", () => { cy.wait(5000); cy.window().then((win) => { cy.stub(win, "open", (url) => { win.location.href = Cypress.config("baseUrl");//domain2 return win.open.wrappedMethod.call(win, url, "_self"); }).as("open"); }); cy.get("element").click(); //which triggers new window with different domain This same code is running fine with chrome and edge but Firefox throwing uncaught exception "SecurityError: Permission denied to define property "open" on cross-origin object" config file already declared with websecurity : false and experimentalthirdpartycode : true
    • 1
    • 1
  • Cypress to wait until custom javascript code to update window cache is completed
    k

    kind-van-46599

    01/19/2023, 1:39 PM
    How to wait for the below code block to complete before I proceed with further execution? In the test I run, the below skeleton will hold Javascript code to modify a table cache to setup test data using queryClient and further step will assert on the values set.
    Copy code
    cy.window().then((window) => {
      const queryClient = window.queryClient;
      /* javascript code to getQueriesData and modify it */
      queryClient.setQueriesData();
    });
    g
    • 2
    • 12
  • How to share data across Cypress 12 tests?
    c

    colossal-balloon-20815

    01/19/2023, 2:17 PM
    I have a table that shows a value somewhere, and I need to make sure that that value is close to other values throughout the page. Since I don't know how much the value will be in advance, I would need to take note of the first value I find and use that as a basis to compare it to all the other values. For that, I would need to be able to save that value somewhere where the other tests could access it. So how to share a value like that?
    g
    e
    • 3
    • 5
  • dockerfile for cypress
    l

    lively-balloon-98986

    01/19/2023, 2:26 PM
    did anyone create dockerfile for cypress running? and have an example for me?
    t
    • 2
    • 2
  • error doesn't show specific row in code
    h

    helpful-coat-87654

    01/19/2023, 3:26 PM
    Before the error message showed a specific row in the code, but now it looks like this, I'm using Сypress 11.2.0
    • 1
    • 1
  • Wait for Animation to Complete
    e

    echoing-tent-95037

    01/19/2023, 4:59 PM
    Hey everyone! I'm having an issue with one of my tests and would love some advice. Currently the test is set to insure a user is able to download a file. All that works, but it is occasionally flaky due to our loading animation. It appears that Cypress is clicking the download button before the animation finishes and a request never gets sent, so my wait for a 200 in the response obviously fails. I've tried adding
    should('not.be.visible')
    for the svg elements of the animation but it always passes even though the animation is still going. Any input on how to handle this is much appreciated. If it helps our svg for this is:
    Copy code
    <svg xmlns="http://www.w3.org/2000/svg" width="80px" height="80px" viewBox="0 0 100 100" preserveAspectRatio="xMidYMid">
        <circle cx="50" cy="50" fill="none" stroke="#3F80F3" stroke-width="10" r="30" stroke-dasharray="141.37166941154067 49.12388980384689" transform="rotate(182.503 50 50)">
            <animateTransform attributeName="transform" type="rotate" calcMode="linear" values="0 50 50;360 50 50" keyTimes="0;1" dur="2s" begin="0s" repeatCount="indefinite" />
        </circle>
    </svg>
    g
    • 2
    • 12
12345...26Latest