https://cypress.io logo
Join Discord
Powered by
# i-need-help
  • My React UI isn't updating with stubbed data.
    b

    bitter-lock-96362

    04/28/2023, 5:19 PM
    Hi all! This is my first time using cypress, and I'm getting hung up on an e2e test. Essentially, I have defined a command with an intercept to respond with JSON data I added to a fixture. I confirmed that I have a 200 response, and the body of the response deeply equals the fixture within a
    .wait()
    . After those tests pass, my UI seems to get stuck in what looks like an in between state. My intuition tells me that this is an issue stemming from the asynchronous
    .wait()
    . However, I do have loading skeletons and a spinner that renders while waiting for data, perhaps that is the issue? The question: Is there a way I can get my UI to update with the stubbed data that I'm missing? I've been digging trough the docs and chatGPT, and It just seems like I have things tied up the way I should. Thanks in advance for any help! Repo: https://github.com/cameronRomo/GameStack/tree/feature/filter-games First screenshot shows the problem, second shows app working without stub.

    https://cdn.discordapp.com/attachments/1101558392935424072/1101558393354858646/Screen_Shot_2023-04-28_at_11.11.21_AM.png▾

    https://cdn.discordapp.com/attachments/1101558392935424072/1101558393677815920/Screen_Shot_2023-04-28_at_11.14.20_AM.png▾

    g
    • 2
    • 18
  • How to deal with element not visible because parent is having display none
    i

    incalculable-rainbow-43330

    04/28/2023, 5:21 PM
    anyone know what's the best way to deal with issue which says "This element is not visible because its parent has CSS property: display: none" instead of using force:true
  • GHA Not Finding Alias
    e

    echoing-tent-95037

    04/28/2023, 7:14 PM
    I have an after call in my test to remove the email inbox that gets created in my test. Everything works perfectly fine locally, but when running within github actions it states that my alias can't be found. Has anyone seen this before and know of a solution? The alias is set in my before hook.
    • 1
    • 1
  • Fetching async value in Cypress test
    f

    future-salesmen-48792

    04/28/2023, 7:21 PM
    I'm having some trouble getting an async value (an array of objects) in a cypress test, and keep playing whack-a-mole with this code. I can see what what the problem is, sort of, but I don't know how to get this global var assigned properly:

    https://cdn.discordapp.com/attachments/1101589129671749744/1101589130212806726/Screenshot_2023-04-28_at_2.50.09_PM.png▾

    e
    g
    • 3
    • 2
  • When loading a page I constantly get Timeout
    p

    powerful-toothbrush-36495

    04/29/2023, 11:17 AM
    So for example th is is the code that I have used.
    m
    e
    • 3
    • 10
  • Cypress CI pipeline does not recognize API calls
    s

    straight-laptop-29696

    04/30/2023, 4:38 AM
    Hi, I have an issue with Cypress CI pipeline for my Vue project. I can run and pass all of my tests with no errors or skips locally. However, when I try running the Cypress CI pipeline on Github Actions, it fails to recognize my API calls and produces various errors. It does not even seem to run API calls as my data won't even load! (It is ok locally) I have tried different codes for my .yml file with no luck! The strange thing is, it sometimes passes some of the previously failed tests but fails new ones! I'd appreciate it if someone could help me out!
  • Cancel run from GitHub Action
    s

    strong-cat-47196

    04/30/2023, 9:21 AM
    When I cancel job in GitHub Action it doesn't cancel run in Cloud so I need to go there and cancel it manually. Is it possible to cancel it from GitHub Action?
    m
    • 2
    • 4
  • Im getting my cypress command name as not a function kindly check the screenshot
    q

    quiet-house-97222

    05/01/2023, 8:49 AM

    https://cdn.discordapp.com/attachments/1102517145885229097/1102517146036219965/image.png▾

    https://cdn.discordapp.com/attachments/1102517145885229097/1102517146296262676/image.png▾

    https://cdn.discordapp.com/attachments/1102517145885229097/1102517146568900668/image.png▾

    https://cdn.discordapp.com/attachments/1102517145885229097/1102517146875080764/image.png▾

    e
    m
    • 3
    • 4
  • (PayPal Sandbox) Testing PayPal payment methods in a checkout flow
    f

    fast-artist-45202

    05/01/2023, 5:47 PM
    I'm testing multiple payment methods in a checkout flow, focusing on PayPal for now. I was able to determine that - PayPal opens a new browser window with an iframe for the end-user to finish authentication and authorize payment - Cypress can't just capture that URL from the iframe and visit that page, as there's some sort of security PayPal implemented that doesn't allow you to finish the flow in anything outside of the provided small pop-up browser window with the iframe. I started following along here: https://whattodevnow.medium.com/testing-paypal-checkout-flow-with-cypress-6c0ebd1321ff I'm having issues right off the bat. In commands.js, I'm using the following:
    Copy code
    Cypress.Commands.add("popup", () => {
      const popup = Cypress.$(state.popup.document);
      return cy.wrap(popup.contents().find("body"));
    });
    and when I run the tests as described in the above tutorial, I'm getting the following:
    Cannot read properties of undefined (reading 'document')
    Has anyone had more success implementing coverage for PayPal checkout options? Is there a better method I could use?
    e
    • 2
    • 9
  • cucumber step with saved progress
    c

    cold-bird-96191

    05/01/2023, 6:41 PM
    Hello. Please advise. How can I create a definition step in which the desired section of my application will be opened in advance and then use this step in other scenarios.
    c
    • 2
    • 2
  • Cypress + OneLogin Enterprise SSO - Duplicate Users
    j

    jolly-window-21891

    05/01/2023, 8:11 PM
    Hi Folks, I am trying to integrate Cypress with our OneLogin for Enterprise SSO. I have everything configured but I am running into an issue. If a user who already had an account on Cypress, it creates a duplicate user with SSO login, rather than associating with the existing user on our account. Is there a setting I am missing? Do I need to reinvite everyone to Cypress via OneLogin? Thank you! Tyler A. IT Manager
    a
    • 2
    • 1
  • Cypress run not waiting Cypress Install to finish causing not found error
    a

    aloof-psychiatrist-45078

    05/02/2023, 4:07 AM
    I want to build a Dockerfile with Cypress installed, Below command is what i tried in Dockerfile
    RUN npx cypress install && npx cypress run
    In the logs below, the terminal seems not waiting for the cypress to finish install, and tries to run cypress directly causing error
    Copy code
    11:58:28  STEP 13/14: RUN npx cypress install && npx cypress run
    11:58:28  Installing Cypress (version: 12.11.0)
    11:58:28  
    11:58:28  [STARTED] Task without title.
    11:58:28  
    11:58:28  > consulting-one-ui@ cy:run /opt/app-root/src
    11:58:28  > cypress run
    11:58:28  
    11:58:28  No version of Cypress is installed in: /root/.cache/Cypress/12.11.0/Cypress
    11:58:28  
    11:58:28  Please reinstall Cypress by running: cypress install
    11:58:28  
    11:58:28  ----------
    11:58:28  
    11:58:28  Cypress executable not found at: /root/.cache/Cypress/12.11.0/Cypress/Cypress
    11:58:28  
    11:58:28  ----------
    e
    • 2
    • 4
  • Cypress - E2E testing : How to login with two different users to execute two different files?
    q

    quiet-dream-68129

    05/02/2023, 5:59 AM
    So my application uses Microsoft login and then redirects back to the application. I am trying to execute two test case files(.js) one after the other. I am doing so by importing them into a spec file and running it. The first step in both files is to login and then perform some task. Each file has different user credentials to login to. The first file with the first user, logs in and executes cases, but when the second file needs a different user login with his credentials, an error is thrown. I am calling a common login function for both files and only modifying the "user" parameter. Can someone help me with a solution? I have mentioned the login function I have. Cypress.Commands.add("login", (user) => { cy.sqlServer(select USERID, password from table name where User=${user}).then(function (result) { var userID = result[0] var password = result[1] const credentials = { userID, password } cy.session([userID, password], () => { cy.viewport('macbook-16') cy.visit('https://websitename.com/') cy.get('.login-btn').click() //clicking accept cookie button cy.get('#onetrust-accept-btn-handler').should('be.visible').click() //clicking microsoft login button cy.get('#microsoft-external-auth-button').should('be.visible').click() //redirected to microsoft login cy.origin('https://login.microsoftonline.com', { args: credentials }, ({ userID, password }) => { //entering username //clicking next //entering password //clicking 'login' button cy.wait(1000) }) }) })})
    c
    b
    • 3
    • 9
  • Define Value Synchronously
    w

    worried-hairdresser-56712

    05/02/2023, 6:01 AM
    Hi, I want to define a value after the Cypress do something first. Here are my codes:
    Copy code
    cy.get("strong + .btn-close").should("be.visible").click().then(function() {
    let text = moment().format("YYYY-MM-DD hh:mm");
    return text
    });
    cy.contains(text).should("be.visible");
    The result is: text is not defined What did I do wrong here? Thank you.
    e
    • 2
    • 1
  • cy.intercept gets wrong response
    w

    worried-hairdresser-56712

    05/02/2023, 7:19 AM
    Hi, so I created these two:
    Copy code
    cy.intercept("GET", "/client/coverage-request-batch/*").as(
          "closingBatchDetailsPage"
        );
    Copy code
    cy.intercept("POST", "/client/coverage-request-batch/*/discardfile").as(
          "deleteUploadedFile"
        );
    But, when the responses is there, Cypress detects the first one, even though the response is 'POST'. Am I doing something wrong? Thank you beforehand.
  • I need help to stop and unregister service worker before my Cypress test runs
    q

    quiet-room-72008

    05/02/2023, 2:37 PM
    Can anyone help me please 1) to stop service worker (started by previous test run? 2) to unregister service worker?
  • Created PR for latest nodejs and browsers version
    p

    purple-afternoon-2408

    05/03/2023, 12:27 AM
    Hello team, I opened a PR here https://github.com/cypress-io/cypress-docker-images/pull/887 for latest image with nodeJS and browser, not sure if I followed the steps correctly, but pls let me know if I'm missing anything.
  • Fail to click a button
    c

    clever-night-39043

    05/03/2023, 6:34 AM
    Hi all I am trying to click a button, but got this error:
    Copy code
    TypeError: Cannot read properties of null (reading 'classList')
    The button is like this
    Copy code
    <button _ngcontent-dxy-c108="" id="CopyBtn" type="button" aria-label="Copy URL" data-bs-toggle="dropdown">Copy Link</button>
    I am not sure what is wrong with it. Can anyone please help? Thanks

    https://cdn.discordapp.com/attachments/1103208026636304434/1103208026929897482/image.png▾

    g
    f
    +2
    • 5
    • 8
  • Update cypress/factory with NODE_VERSION 20 openssl dpkg error
    w

    white-appointment-55436

    05/03/2023, 8:36 AM
    I am trying to use cypress/factory as my base image to build out our custom gitlab CI runner image but with NODE_VERSION=20.0.0. However, it seems specifying this version causes/requires openssl to be installed and that triggers an interactive dpkg prompt. I would like to overwrite and provide this apt-get option of --option=Dpkg::Options::=--force-confdef to default interactive answer to accept openssl install so that node-version 20.0.0 can be installed. Any recommendation how I can update the base dockerfile for cypress/factory at https://hub.docker.com/r/cypress/factory ?
  • What is better for E2E: testing library or data-test id?
    b

    billowy-petabyte-65450

    05/03/2023, 2:14 PM
    I am building an automation framework using Cucumber, Page Object Model and Cypress, and I am not sure if it is better to use Data-testid or testing library, as Best Practice of Cypress recommends using data-testid, but on the other hand, a lot of people suggest using testing library, and the best options which are recommended by Testing Library are to use findByRole or findByText (instead of testid), it means, the opposite of Best Practice of Cypress. On the other hand, if I use testing library, I don’t understand what is the goal of cypress assertions like webElement.should('have.text', 'expectedText'); as this webElement must be caught using the text by findByRole or findByText, and if the text isn’t the expected the webElement won’t be caught, so I see the duplicity of actions using testing library. What is your recommendation? Thanks for the help
    g
    f
    w
    • 4
    • 18
  • Attempting to login to Twitch using Cypress e2e
    f

    future-journalist-95278

    05/04/2023, 12:16 AM
    I'm following along with https://docs.cypress.io/guides/end-to-end-testing/social-authentication#Testing-with-Cypress except with Twitch values and am running into the error
    Your browser is not currently supported. Please use a recommended browser or learn more here.
    . The code I am running is here:
    Copy code
    ts
    
    Cypress.Commands.add('logIntoTwitch', () => {
      logIntoTwitch(Cypress.env('TWITCH_USER'), Cypress.env('TWITCH_PW'))
    })
    
    function logIntoTwitch(username: string, password: string) {
      cy.visit('http://localhost:3000/api/auth/signin?callbackUrl=%2Fdashboard')
      cy.get('button').click()
    
      cy.origin(
        'https://www.twitch.tv/login',
        {
          args: {
            username,
            password,
          },
        },
        ({ username, password }) => {
          cy.get('input[id="login-username"]').type(username)
          cy.get('input[id="password-input"]').type(password, {
            log: false,
          })
          cy.get('button[data-a-target="passport-login-button"]').click()
        }
      )
    }
    Visually, it works just fine. Clicking the correct input fields, typing, and submitting the expected data. The issue is Twitch is saying the browser spawned within the E2E test isn't supported. Is there something I may be able to do to make this work?

    https://cdn.discordapp.com/attachments/1103475121118785659/1103475121680810017/FvPjTvaaIAEwocS.jpeg▾

    c
    • 2
    • 2
  • Cypress MySQL connection
    q

    quiet-room-72008

    05/04/2023, 7:43 AM
    Has anyone used successfully the plugin cypress-mysql ?https://www.npmjs.com/package/cypress-mysql? If you have used any other method successfully to connect to MySQL DB, please mention.
  • Hydration failed because the initial UI does not match what was rendered on the server
    p

    purple-afternoon-2408

    05/04/2023, 7:52 AM
    Hello team, I am trying to write E2E for react, but I get this error, not sure why. Can anyone please help?
    b
    • 2
    • 4
  • Error while testing to login to my project + gitlab ci/cd
    g

    gray-fall-5541

    05/04/2023, 8:21 AM
    I built my project in React JS and wrote a component test to login through a particular email and password. It is supposed to work fine but i am getting some unusual errors like this
    Copy code
    error:- The following error originated from your test code, not from Cypress.
    
    
    
    > Cannot access 'WEBPACK_DEFAULT_EXPORT' before initialization
    
    
    
    When Cypress detects uncaught errors originating from your test code it will automatically fail the current test.
    
    
    
    Cypress could not associate this error to any specific test.
    
    
    
    We dynamically generated a new test to display this failure.
    . what can be the possible solution for this error (I researched about this error but did not find any clue) ?
  • Cypress freezes on mac https://docs.cypress.io/guides/getting-started/installing-cypress
    p

    purple-afternoon-2408

    05/04/2023, 8:46 AM
    Hello, I have mac M2 and cypress works for some period of time then freezes, is there any requirements I am missing? https://docs.cypress.io/guides/getting-started/installing-cypress
    e
    b
    • 3
    • 7
  • window.Cypress is undefined from the app code, but I can see it defined inside the Cypress GUI
    e

    echoing-kangaroo-83836

    05/04/2023, 1:26 PM
    I'm working on automated testing of a React/Next application. One of the pages has some logic in a
    useEffect()
    and then does a
    window.open()
    passing
    _blank
    as it's second argument like
    window.open(url, "_blank")
    which causes it to open in a new tab. While running inside Cypress I want to change this to
    _self
    so I can test the URL was properly navigated to. At the top of the
    useEffect()
    I'm setting a variable for this using
    const openLocation = window.Cypress ? '_self' : '_blank';
    and then passing
    openLocation
    to the
    window.open()
    call. The problem I'm running into is
    openLocation
    is always
    _blank
    even though when I'm running cypress I can go to the console and do
    window.Cypress
    and see there is a Cypress object defined there. Is this some sort of race condition?
    • 1
    • 3
  • How to do visual testing for DeckGL in React
    f

    few-ability-10425

    05/04/2023, 1:30 PM
    Hey all, I've tried searching for this and believe it's a new question (please point me towards the thread if there already is one) I'm trying to build visual regression tests for our map in DeckGL and I'm having issues finding a tool that can capture screenshots of the map once it's loaded. I've tried Percy and as it only run's in headless mode, I've had issues getting any screenshots with the map rendered. Do you know of any way to achieve what I am after? Ideal state is to have a test that interacts with some basic functionalities of the map (zoom in/out for example) and then takes a screenshot for comparison.
    b
    s
    • 3
    • 2
  • mochaweseome/addContext is not doing anything in recent versions of cypress
    m

    magnificent-animal-85146

    05/04/2023, 1:32 PM
    I am trying to addContext to a test using mochawesome but it is not doing anything, it should be adding a context after I run the test. const addContext = require("mochawesome/addContext"); afterEach(function () { addContext(this, 'simple string'); }) describe("Iamgenes ", function () { it.only("Prueba 2", () => { }); });
  • How can I skip a failure on a response code on a non cy.request() test?
    f

    faint-ocean-92094

    05/04/2023, 5:17 PM
    Hey everyone. I have a strange case, pointless to test really but I was asked by a customer. They have settled a limit of 100 requests to a page, and at 100 they show a recaptcha. The test I need to do is basically visit a page 100 times, and at that point the page will return a 405 and the test will crash. So I added a loop. Simply:
    Copy code
    var count = 100 
    for(var i = 0; i < count: i++) {
      cy.visit("https://mypage.com")
    }
    Now at some point between 95 and 100 (because it depends on other tests that could visit this page more than once) the test will crash saying the page responded with a 405 and did not respond with 20x code. That all makes sense and it is the correct behavior. My question is, what would be the correct way to stop the loop (or complete it, doesn't matter) when I get this response and just continue till the end so I land on the captcha page. I just need to verify the captcha appeared so it is pretty straight forward. I just can't make the
    failOnStatusCode: false
    because it is not a request block. Any recommendations?e
    g
    • 2
    • 4
  • How to find the iframe I am looking for if 3 are found?
    b

    brainy-army-77830

    05/04/2023, 6:15 PM
    Hello guys, I am dealing with a Plaid cross origin iframe(using the react-plaid-link library) and using the cypress-iframe library. I have my test working 90% of the time because the ID for my iframe is usually #plaid-link-iframe-2 but the problem is that I cannot make a general one right now because there are for some reason 3 iframes being detected, and sometimes the iframe populated with things is #plaid-link-iframe-1, or possibly #plaid-link-iframe-3. How should I go about trying to find the correct iframe ID? One button I can try to find is of id "#aut-button" which is the continue button I should be seeing. Thank you!
1...202122...26Latest