https://cypress.io logo
Join Discord
Powered by
# help
  • f

    famous-restaurant-30435

    09/23/2022, 3:05 PM
    I did some digging into this and it appears the screenshotOnFailure behavior is not configurable which is a bummer. I would really love to capture the full page on failure.
  • m

    mysterious-belgium-25713

    09/23/2022, 3:54 PM
    I think you can do it with the screenshot api https://docs.cypress.io/api/cypress-api/screenshot-api The Screenshot API allows you set defaults for how screenshots are captured during .screenshot and automatic screenshots taken during test failures. You can set defaults for the following:
  • f

    famous-restaurant-30435

    09/23/2022, 3:55 PM
    Ya this is according to the docs: "For screenshots automatically taken on test failure, capture is always coerced to runner."
  • f

    famous-restaurant-30435

    09/23/2022, 4:04 PM
    Id love to find a way to configure this. Im unsure why we can only screenshot the runner window when a failure occurs.
  • c

    clever-table-91477

    09/23/2022, 5:05 PM
    @abundant-dentist-45237 click on your avatar --> my account --> email --> edit
  • c

    clever-table-91477

    09/23/2022, 5:16 PM
    @here Not sure what I'm doing wrong. Xpath doesn't work for me. What I've done was : 1. Installed xpath plugin, added
    require('cypress-xpath');
    in
    setupNodeEvents(on, config) {}
    block as well as in
    e2e.js
    , not sure where exactly it should go. Then when I run the test with cy.xpath(''), it fails with this error
    cy.xpath is not a function
    . Maybe someone can help me, it must be something obvious that I don't see
  • m

    mysterious-belgium-25713

    09/23/2022, 5:16 PM
    And if you would try that on failure to just create a screenshot. This is an example that uses debugger but maybe you can also do a cy.screenshot.
    Copy code
    js
    Cypress.on('fail', (error, runnable) => {
      debugger
    
      // we now have access to the err instance
      // and the mocha runnable this failed on
    
      throw error // throw error to have test still fail
    })
  • a

    abundant-dentist-45237

    09/23/2022, 5:30 PM
    I cannot enter a new email. It only lists the one already used and cannot be edited.
  • b

    brave-river-4142

    09/23/2022, 5:49 PM
    Hello guys, I'm trying to create a test where the mouse pointer clicks and drags a card (like in trello), but I didn't find much information available. I would like to know if anyone has done it, how did it and etc. Thanks 😊
  • m

    mysterious-belgium-25713

    09/23/2022, 6:42 PM
    Hi @clever-table-91477, the only place you need to put the
    Copy code
    js
    require('cypress-xpath');
    Is in the file cypress/support/e2e.js
  • f

    famous-restaurant-30435

    09/23/2022, 6:50 PM
    Yep Ive tried this one too. It doesnt respect the screenshot configuration.
  • m

    mysterious-belgium-25713

    09/23/2022, 7:40 PM
    I found a trick, havent perfected it yet but its based on the metaprogramming page of Gleb. I have now in my e2e.js file the following code.
    Copy code
    js
    import './commands'
    
    var isFailed = false;
    var failedTitle;
    
    Cypress.on('fail', (error, runnable) => {
      
      failedTitle = runnable.fullTitle();
      isFailed = true
    
      throw error
    })
    
    afterEach(function() {
      if(isFailed){
        cy.screenshot(`The failed test is ${failedTitle}`,{capture: "fullPage"})
        isFailed = false
      }
    })
    This gives you 2 screenshots one the default when it failed. And the second a screenshot that makes a fullpage with the failed test title. Hope this will help you
  • f

    famous-restaurant-30435

    09/23/2022, 7:45 PM
    Oh awesome! I’ll try this later and report back
  • m

    mysterious-belgium-25713

    09/23/2022, 7:45 PM
    Sure let me know, during the weekend i'm not that responsive but would be happy to hear if it also works for you.
  • g

    gray-kilobyte-89541

    09/23/2022, 8:55 PM
    so I like this approach, just have this in mind that the app might change between the failure and the "afterEach" hook
  • l

    limited-barista-33480

    09/24/2022, 12:36 AM
    Hello guys, can someone help me with this error, I'm trying to run a cypress test that contains this type of aws certificates. and I do not identify what problem it is or how I can solve it. I made some configurations of Cypress Webpack, but it does not run for me. Error: Webpack Compilation Error ./cypress/cert_pre/AmazonRootCA1.pem 1:4 Module parse failed: Assigning to rvalue (1:4) You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders > -----BEGIN CERTIFICATE----
  • s

    strong-energy-6158

    09/24/2022, 6:32 AM
    I have three cypress scripts. Now I am doing login each time. I want to avoid login in each time by preserving cookies. Can you please let me know how we can achieve it? any sample code is preferred.
  • s

    stale-optician-85950

    09/24/2022, 8:12 AM
    "Cache and restore cookies, localStorage, and sessionStorage in order to reduce test setup times." https://docs.cypress.io/api/commands/session
  • a

    adventurous-rose-66394

    09/24/2022, 8:43 PM
    Hey, i just found a typo on the cypress> guides on the webpage, where should i report it?
  • s

    strong-energy-6158

    09/25/2022, 6:40 AM
    Thanks. I tried this but not working for me. Is there any working sample repo?
  • m

    microscopic-advantage-2187

    09/25/2022, 7:08 AM
    Hello I have specific scenario where I need to run 2 test files before all other files how to achieve this? I don't want to use
    before
    in support files since I only want to run them once and before the other files
  • l

    little-umbrella-9653

    09/25/2022, 7:45 AM
    Hi Guys when I open cypress and run tests..left side panel is displaying logs..but once user nameis entered ...left side panel disappeared ...and also locator for password is not working to type password... any comments onthis?
  • d

    dazzling-pillow-26039

    09/25/2022, 7:53 AM
    https://docs.cypress.io/api/plugins/before-run-api#Syntax you can use before: run API but also there is a catch here. If you are running them in parallel. This executes for each machine. If it is some kind of data gen. I would recommend you run only these steps in a separate step in CI/CD either by having these entries in a separate config.ts or pass the spec files as part of arguments. Later you need to add these to ignore files for the main run.
  • m

    microscopic-advantage-2187

    09/25/2022, 8:05 AM
    I read this and for some reason didn't work also, can I list more than 1 file there?
  • f

    fancy-mechanic-10638

    09/25/2022, 8:10 AM
    When I do
    cy.intercept('post', '/path', {fixture: 'someFile'})
    is there a way to then modify the file beyond that? It's a big JSON object, and for the 4 tests I want each one to slightly change a few values.
  • m

    mysterious-belgium-25713

    09/25/2022, 1:22 PM
    I think you can do it if you don't use the fixture. You can use a js import to get the JSON. Then edit the JSON in your test/before the testcase. And use that as the body for your intercept.
  • f

    famous-restaurant-30435

    09/25/2022, 2:01 PM
    This is accurate. You can do something like the following.
    Copy code
    javascript
    cy.fixture("calculator/monthlyRepayment.json").then((json) => {
      cy.intercept("POST", "**/full", (req) => {
        //you can use the request here if you need data that is included in the request
        let name = req.body.username;
        json.username = name;
        req.reply(json);
      });
    });
    You can see more documentation here: https://docs.cypress.io/api/commands/intercept#Controlling-the-outbound-request-with-req-continue
  • b

    bulky-park-99069

    09/25/2022, 6:24 PM
    Am new to cypress.. and am not understanding how to loop on a list element.. and get anchor tag value, click and perform validation on it.
  • b

    bulky-park-99069

    09/25/2022, 6:26 PM
    Could anybody help me with this?
  • s

    stale-optician-85950

    09/25/2022, 6:39 PM
    In fairness
    cy.session()
    is well documented on that page, so I'm not sure what extra you're expecting in an example repo. Anyhow you can also use this plugin from @gray-kilobyte-89541 https://github.com/bahmutov/cypress-v10-preserve-cookie
1...152153154...252Latest