https://cypress.io logo
Docs
Join the conversationJoin Discord
Channels
ama-josh-justice
ambassador-playground
angular
best-practices
component-testing
cy10-feedback
cypress-announcements
cypress-cloud
cypress-feedback
cypress-frameworks
cypress-frameworks
cypress-plugin
cypress-updates
e2e-testing
experimental-tools
general
general-new
help
how-to-get-help
i-made-this
i-need-help
introduce-yourself
jobs
plugin-channel
react
real-world-app
resources
rules
vue
welcome
Powered by Linen
general-new
  • have.text fails but the text is the same
    r

    red-toddler-79937

    02/13/2023, 5:23 AM
    Hi, does anyone know how I can solve this: My HTML file:
    html
    <div class="flex flex-row p-2 text-sm border rounded box w-fit" data-testid="add-ons-label">
      {{ name }} - {{ priceInCents / 100 | currency }}
    </div>
    My Cypress file:
    ts
    cy.findAllByTestId('add-ons-label').first().should('have.text', ' Cola - € 0,02\n');
    Thank you in advance!
    r
    a
    • 3
    • 41
  • can I use cy.origin in a loop?
    p

    purple-afternoon-2408

    02/14/2023, 6:14 AM
    Hello, I have a usecase where I need to run cy.origin in a loop, it doesn't work on the second loop start
    b
    • 2
    • 2
  • Testing a form over multiple pages
    a

    acceptable-oxygen-27042

    02/14/2023, 3:13 PM
    Hello, I am fairly new to Cypress and my question is, is it possible to write a script that would test an application form that spans a few pages but separate the tests into different it statements. This is without the user having a log in. For example the form I am testing page 1 is the users personal details then page 2 is payment details etc. I know that this could be achieved in one single it statement but surely this isn't best practice? I hope this post makes sense. Even if anyone has some good resources or videos to point me towards that would be amazing.
    g
    • 2
    • 2
  • Download File And Verify
    e

    echoing-tent-95037

    02/15/2023, 4:45 PM
    Just wanted to ask if the standard way of checking files that have been downloaded is by using the
    cypress-downloadfile
    package? Wasn't sure if there was a native way with Cypress, from a quick look at cypress.io documentation I didn't see anything.
    • 1
    • 2
  • Angular component testing: How to handle child components? Do we access their internals?
    m

    mysterious-jackal-38863

    02/16/2023, 12:46 PM
    Hi guys, I'm a noob so be gentle 🙂 . how do you approach child components? Heres what I'm currently doing.. I have a pets card component, inside that I have a pets list component and a download button. I pass an array of Pets to the PetCard and it passes it to PetList. I have already written tests for the PetList. Now I want to test the PetCard to enable the download button if theres pets available. Something like this... it("can download if theres pets available in the list", () => { const pets: PetViewModel[] = [pet]; cy.mount(PetCardComponent, { ...config, componentProperties: { pets: pets, }, }); cy.get('app-pet-list').should('exist'); cy.get('.mat-row').should('have.length', 1); // ToDo : more tests to confirm we can downloasd }); ------------ Pet card pet-card works! Download <{{pets.length}} export class PetCardComponent { @Input() pets: PetViewModel[] = []; constructor() {} } ------------ Im having trouble with the bolded line accessing the count of rows in the list cy.get('.mat-row').should('have.length', 1); It fails to be found. It looks like the list isnt rendered at all in the browser even though the previous should(exist) passes. Thats my immeditate problem. But should I even be attempting to check the internals of the child component like this? Are you guys accessing child compoments internals deep in the structure of your parent components? I'd love to find a sample app showing best practices in this area, but i cant find any.
    r
    • 2
    • 6
  • Visual Testing
    c

    crooked-megabyte-18846

    02/17/2023, 3:13 PM
    Im looking at various visual testing toolsets to work alongside our Cypress tests. We understand that many of the free plugins will look at pixel by pixel and for our purposes, that would create allot of noise. Does anyone have experience of the various paid solutions? and any opinion of which may be better/best?
    b
    s
    +4
    • 7
    • 13
  • Issue with Cypress 12.5.1 and require
    m

    melodic-artist-76036

    02/20/2023, 4:36 PM
    I have a strange issue which I can't even explain properly. I am using
    cy.origin
    and
    require
    to import dependencies. Those dependencies are local modules (page objects) which I need for assertions. Locally, everything works like a charm, but on CI I get this error:
    Error: Error: ENOENT: no such file or directory, open '/tmp/cypress/webpack-preprocessor/36c17fa865a97b9d11c9436638e044d7/cross-origin-cb-948eb7e9dc3ceb4e5222da0c9c591d18.js'
    Now before posting the whole setup, does anyone have an idea what could be the issue here? It seems it can not find the sources required for cross origin callbacks.
  • Environment variables in the github actions
    m

    most-baker-72677

    02/22/2023, 12:09 PM
    I have a repo that runs on GitHub. This repo contain two cypress projects. I have a
    cypress.env.json
    file in the root of the project that contains
    AGENT_API_KEY = key
    When I commit the project this
    cypress.env.json
    file will contain
    AGENT_API_KEY = <your api key>
    as each developer will need to put in their own api key. In the gitHub actions pipeline I will use:
    env: 
        CYPRESS_AGENT_API_KEY: ${{ secrets.CYPRESS_AGENT_APIKEY }}
    Looking at the docs I am finding it a little difficult to predict whether the
    CYPRESS_
    will be dropped, case maintained or normalised in someway. What should happen in this case? I am working on the basis that the
    env
    variable in the action will be preferred to the
    cypress.env.json
    in this case
    n
    • 2
    • 7
  • cypress firebase authentication issue
    b

    bumpy-intern-64580

    02/25/2023, 5:04 AM
    Hi everyone, I am a new bee to cypress and trying to login to an application which uses firebase authentication. I followed the tutorial available on medium and github but still facing some challenges. When i login i am able to visit the landing page but when navigating to further pages it says unauthorised access. I guess the problem is somewhere with local storage where I can only see the token not the authorised user. If anyone can help me in this would be a great help. Thanks! in advance.
  • Is there any easy way to do soft assertions in cypress?
    n

    narrow-coat-44595

    02/27/2023, 5:22 AM
    Need a way to do soft assertion in while running for each loop. Can someone please guide me?
    g
    • 2
    • 2
  • Attach Bug Ticket to Failed Tests
    e

    echoing-tent-95037

    03/01/2023, 5:53 PM
    Is there a way to attach bug tickets to failed tests in cypress dashboard? It would be nice to have as a reminder for some tests that are failing due to a bug that has been reported.
    b
    a
    • 3
    • 4
  • Random popup
    n

    narrow-coat-44595

    03/02/2023, 7:45 AM
    Is there any way to handle random popup using cypress? For example: Sale popup which comes randomly in some pages and sometimes it doesn't come. There are 2 random popups like that. Can someone please suggest me how to do this. I have been using cookies but after it loads the new page sometimes the test case fails due to popup and sometimes since the popup is not there it gives error, cookies not found. Please help..
    b
    b
    • 3
    • 2
  • postmessage
    b

    busy-tailor-13324

    03/02/2023, 6:02 PM
    I am trying to get the Cypress Real World App running using an Okta OIDC (authentication code flow) and am having no luck using either okta_programmatic_login code path or the default. Is there someone that might be able to help me with this?
  • Web enabled TV device testing with cypress
    s

    straight-grass-43954

    03/03/2023, 10:32 PM
    Hey there! I'm a web developer who works on applications that are made for web-enabled tv devices. I actually have two questions. 1.) One of the devices we work with is using webkit. https://developer.comcast.com/documentation/learn/latest/device-specs I know that it is currently in experimental and I'm interested in contributing to that effort. However I'm having a hard time finding what versions of webkit will be supported with the current implementation, and I'm also unsure what version cypress is aiming to support when it goes stable. If there is a plan for a supported version, could I make a pr to update the docs for browser support to reflect that? https://docs.cypress.io/guides/guides/launching-browsers#Browser-versions-supported 2.) Often times the tv devices we work with while being rather new, use really old versions of chrome that aren't currently supported by cypress. Is there any effort or interest in expanding our chrome support to go back any farther than 64? Once again, I'd be willing to contribute to this effort. Just to name a few devices that wouldn't be covered in the current support: All Samsung tv's 2019 and older: https://developer.samsung.com/smarttv/develop/specifications/web-engine-specifications.html#Web-Engine-Version LG tv's 2019 and older: https://webostv.developer.lge.com/develop/specifications/web-api-and-web-engine Thanks!
    b
    r
    • 3
    • 4
  • Cucumber with cypress
    s

    silly-journalist-41771

    03/05/2023, 7:03 PM
    Anyone have experience using cucumber with cypress, maybe a guide or publicly available repo I can look at :)?
    b
    a
    c
    • 4
    • 7
  • Genuinely curious how folks would approach this scenario
    e

    echoing-hamburger-46900

    03/06/2023, 5:13 PM
    You need to perform a series of tests, consider each is a separate test case and they don't necessarily belong to the same test suite; 1. Test Login functionality 2. Test that you can create a new object as part of a web application 3. Test you can edit this object 4. Test you can delete the object You also need to keep your environment clean, you're using a test environment which is permanently deployed so it can be tested against manually as well. Just curious how everyone else would approach this, because i'm new to using Cypress and things seem to be done a little differently around here than what i'm used to (coming from Selenium). As for me, I'd have each of those as a spec, except the login which would also be written as a separate utility because you'd need to login to the online application in order to perform and testing at all, so why repeat that code over and over. Same can be said for removing the object created, I'd probably have that as a utility too, because we need to clean up after the tests and remove any objects created so that the application is clean after testing (and what i mean by this, is that if for example tests run daily and create an object each time they we want to test that one can be created and that one can be edited you'd end up with 2 a day that just clutter up the application until someone removes them). Going forward; 1. Test Login functionality using util => add assertions to confirm that login works 2. Test that you can create a new object as part of a web application, perform the creation workflow, then the utility to remove the object. 3. Test you can edit this object, depending of the amount of combinations and if the object would need to be recreated to have different config options i'd either have the creation flow in a utility too or just create it once at the start of this test. 4. Test you can delete the object, again, use the utility and then assert How would you handle this kind of scenario?
    t
    • 2
    • 2
  • Code Coverage Typescript
    s

    shy-ambulance-32896

    03/07/2023, 5:16 PM
    Hello, I have an issue once i added option to get the raport about code coverage. Please see the screenshot. Could somebody help to do it correctly?
    m
    • 2
    • 6
  • AAD Service Principal or AAD user with MFA login
    s

    stocky-grass-9933

    03/08/2023, 8:44 PM
    Is it possible to use a service principal to login to an application using MSAL? I am trying to write an automated test in cypress to login via a service principal. I need to get a token for the service principal and cache it so that MSAL recognizes a signed in user exists and doesn't redirect me to login, however I still get redirected to login.
    • 1
    • 1
  • Error when render the asterisk for EUR pricing
    a

    agreeable-alligator-92650

    03/09/2023, 3:19 PM
    message has been deleted
    b
    • 2
    • 2
  • Cypress - Visual Regression tests
    f

    fancy-painting-32155

    03/09/2023, 8:31 PM
    I'm writing visual regression tests and would like to know how to disable the orange border during the run. See pic. This orange border/highlight is not from our code. It appears during cypress run. And when taking screenshot it shows on the screens.
    m
    c
    g
    • 4
    • 9
  • How to interaction cypress-browser-permissions plugin with cypress version >10
    a

    agreeable-lamp-9666

    03/12/2023, 9:35 AM
    Hi everyone, For those who go out to work with the plugin on cypress version <10, what should be changed in the interaction to cypress >10? https://www.npmjs.com/package/cypress-browser-permissions Thanks for your help🙏
  • Does anyone have a good article on scalable architecture for mocks that require lots of mutating?
    b

    busy-agency-3812

    03/13/2023, 9:02 PM
    I'm inheriting a cypress project where the way they scaled was to create a JSON fixture for every possible scenario and change one little thing about it. This results in hundreds of these fixtures that are virtually identical except small changes here and there. Worse, when developers add to the API, it forces me to update 150 fixtures with the exact same change. This isn't scalable but i'm not having great results searching google about how to create some sort of class that an intercept can reference without calling the entire structure in the test. Like yes, i can do a cy.intercept and pass these extremely long json responses directly but that would be almost just as bad.
    e
    • 2
    • 5
  • Generated Forms.
    b

    bitter-match-90736

    03/16/2023, 8:38 AM
    Hello guys from the forge of the brilliant and sometimes frustrating framework. My concern and request may not be intended for e2e testing or even for Cypress. Or maybe my skills are too poor. But is there a best practice for recursive methods? The asynchronous aspect is driving me crazy. I can't keep wrapping everything. What I want to test is just a form generated by the backend. And my code should just recognize and fill in all the fields and dropdowns. Well, it does this so far. But some fields have dependencies on others. And that's where my issue is - synchronously it would work perfectly. But no, it's doing the fields first that it should do as the next step. Is there a workaround for this? Cheers
    g
    • 2
    • 6
  • Tests feel unreliable
    e

    echoing-hamburger-46900

    03/16/2023, 12:02 PM
    My test run in github actions and they seem incredibly fragile, I'm really struggling to get consistent results. I'm testing a webapp and even performing things like clearing inputs, entering values, opening and closing modals is frustratingly unreliable. I've tried to steer clear of static waits as much as I can but even then it's almost like there's always a misalignment between command and what's happening in the UI. I can run a test run and 10/10 pass, next day, nothing changes and only 8/10 pass, i can rerun and 6/10 pass and rerun again and 10/10 pass. And we're really not talking anything complicated, it's as simple as "click tab X, make a thing happen, wait for new thing to show, assert if new thing is visible." Has anyone else experienced this sort of thing? Any tips or suggestions on how to handle it, because I'm losing my mind and have 0 trust in the current tests.
    b
    a
    +3
    • 6
    • 15
  • Why .clear() scrolling element to the top ?
    b

    bulky-iron-63109

    03/16/2023, 1:38 PM
    Hi community, Really I'm confused, don't know why but .clear() scrolling the element back to top even when I call scrollIntoView({offset:{top:-500}}) then .type("xxxxx"). In pic2 , I have manually scrolled to see that "xxxx" has been typed, so if typed, that means placeholder is visible then why .clear() scrolling the element back to top ?
    e
    n
    • 3
    • 7
  • Newcomer....e2e kitchen sink launching browser and not running tests
    f

    freezing-midnight-9121

    03/16/2023, 2:17 PM
    Went through steps (repo, node install, angular, etc.) and running: ng verision shows: Angular CLI: 15.2.4 Node: 18.15.0 Package Manager: npm 9.5.0 OS: darwin x64 Angular: 15.2.2 ... common, core, platform-browser-dynamic Package Version --------------------------------------------------------- @angular-devkit/architect 0.1502.3 @angular-devkit/build-angular 15.2.3 @angular-devkit/core 15.2.3 @angular-devkit/schematics 15.2.4 @angular/cli 15.2.4 @schematics/angular 15.2.4 1. Open terminal, navigate to project and ran: npm start 2. Open another terminal and ran: npm run cy:open 3. Select E2E testing and select Chrome 4. Click "Start E2E testing in Chrome 5. Browser opens w/About:blank, Chrome is being controlled by automated test 'software' 6. Terminal from step2 shows: "Still waiting to connect to Chrome, retrying in 1 second (attempt 18/62)" 7. nothing is happening in the window invoked 8. Opening a browser window with: http://localhost:8080 brings up kitchen sink and I can see activity in my window from step 1. Any help would be appreciated....
  • is not a function
    r

    rough-jordan-79228

    03/17/2023, 2:02 PM
    Hey everybody, I am facing a weird Error. I have two functions in my commands.ts file. 1. checkS() 2. checkG() In my test I want to use the functions depending on the Environment im using: If(env.lic == 1) { ''''cy.checkS() } else if(env.lic == 2) { ''''cy.checkG() } . . . If I run the Code with env.lic == 1 it finds the function and runs the whole Code. = OK If I run the Code with env.lic == 2 it dont starts the Tests at all and directly says -> cy.checkG is not a function Both functions are in the same file and both are doing the same just with different informations. If you have any Plan what I could try -> thank you in advance
    • 1
    • 1
  • To POM or not to POM
    e

    echoing-hamburger-46900

    03/22/2023, 11:12 AM
    So I've been playing with the idea of starting to use POM with cypress I've looked around and read the famous 'Stop using Page Objects and Start using App Actions' by Gleb. We have a live page for testing which contains anonymous data, most of the app is focused on visualising data and allowing users to manipulate it so a lot of user interactions, modals.. We run testing in CI, the automated testing suite isn't currently very big but will grow, as it stands all our automated tests take approx. 15 minutes to run (this includes the startup jobs), so time isn't necessarily an issue. I'm pretty set on starting to implement POM, but wanted to ask if anyone has any tips and/or suggestions on the implementation, any pitfalls or just useful things organisation tips. I previously did this same exercise at an old company, except using python/selenium which worked quite well.
    g
    • 2
    • 2
  • Credit Card iframe on WebKit
    b

    bulky-iron-63109

    03/22/2023, 4:55 PM
    Trying to enter CC details under iframe on WebKit (the command works for chrome) , but the document is not visible. Do you guys have a trick for it ? See attached DOM. and here is the code i'm using to get the cardnumber placeholder. cy.get('[data-test="basket-payment-card-number"] > .__PrivateStripeElement > iframe') .should("be.visible") .its("0.contentDocument.body") .then(cy.wrap) .find("[name='cardnumber']") .should("be.visible") .type(cardNumber); So 0.contentDocument.body is not available. see attached. Then I have printed only "0" to see what we have under it and saw only main #document.
  • Unable to call custom command cypress method in after:run plugin
    a

    agreeable-motorcycle-46564

    03/22/2023, 9:33 PM
    Have you used on on("after:run", (results) => { I am using in my project to send slack message using slack webhook api in after:run I'm getting below error, I have created a custom command and created a method in apiutils to call that custom command ... was thrown in your plugins file while executing the handler for the after:run event. The error we received was: TypeError: Cannot read properties of undefined (reading 'postToSlack') at Function.ApiCypressUtils.postToSlackChannel (/Users/anil.bheema/Documents/workspace/convex/e2e_tests/cypress/orca/cypress/src/utilities/api-cypress.utils.ts:7:12) The error we received was: TypeError: Cannot read properties of undefined (reading 'postToSlack')
Powered by Linen
Unable to call custom command cypress method in after:run plugin
a

agreeable-motorcycle-46564

03/22/2023, 9:33 PM
Have you used on on("after:run", (results) => { I am using in my project to send slack message using slack webhook api in after:run I'm getting below error, I have created a custom command and created a method in apiutils to call that custom command ... was thrown in your plugins file while executing the handler for the after:run event. The error we received was: TypeError: Cannot read properties of undefined (reading 'postToSlack') at Function.ApiCypressUtils.postToSlackChannel (/Users/anil.bheema/Documents/workspace/convex/e2e_tests/cypress/orca/cypress/src/utilities/api-cypress.utils.ts:7:12) The error we received was: TypeError: Cannot read properties of undefined (reading 'postToSlack')
View count: 1