https://cypress.io logo
Join Discord
Powered by
# i-need-help
  • Cypress run (headless) retry does not seem to be true retries?
    f

    flaky-article-23611

    01/19/2023, 6:17 PM
    I am currently having some issues running a test headless. It seems that retries are not true retries. I don't run tests in isolation mode, but this test is isolated, being the only test within this file. So I noticed a test failing and went and looked at the logs and screenshots. To my surprise the first attempt fails differently then the next attempts. In this case it happens with dragging and dropping a file on to my page. My tests looks like this: Before hook: Visit webpage Start test Load file Do checks if file has loaded Currently fails due to a slight change in code on the web page side Now the next try will show me that two files have been uploaded where as this is never done in the test. I have some other tests where I'm seeing this behaviour too and I can't really explain it or say it's due to flaky tests. It really seems that the retries are not true retries. I'm currently on Cypress version 12.0.1 and use Chrome 109 for the tests to run in. Unfortunately I can't share any code or screenshots due to company policy. Thanks in advance
    g
    e
    • 3
    • 3
  • Cypress & Drag and drop
    n

    narrow-cpu-2218

    01/19/2023, 9:59 PM
    Hello, i've been trying to drag and drop an item from a column, into an element. I've tried mouse events :
    Copy code
    cy.get('#icon_text').focus().trigger('mouseover').trigger('mousedown', { button: 0 }).trigger('mousemove', 1000, 200, { force: true }).trigger('mouseup', { button: 0 })
    I've tried trigger():
    Copy code
    cy.get('#icon_text').first().trigger('dragstart', { dataTransfer: dataTransfer })
            cy.get('#mainmap').trigger('drop', { force: true }, { dataTransfer: dataTransfer });
    But nothing seems to be working. My page looks something like this:
    s
    • 2
    • 3
  • How to call CDP to take screenshot after test run?
    g

    great-oil-15113

    01/19/2023, 10:18 PM
    Cypress.automation can take screenshot in 'afterEach' but not in 'test:after:run'. Is there a way?
  • Cypress Component testing + NextJS `/app` directory error
    j

    jolly-horse-95708

    01/20/2023, 9:32 AM
    I am writing a component test and this component has a
    <Link>
    component inside which has a dynamic href like
    Copy code
    href={{
            pathname: '[job]/quote',
            query: router.query,
          }}
    Now this works just fine, however, it seems that if using the new
    /app
    directory in the new version of NextJS this doesn't work anymore. Only problem is... I'm not using that at all. Is there any way to tell cypress that I am not in fact using the
    /app
    directory and that I'm still using the old page file routing?
    b
    h
    • 3
    • 4
  • Tests passing percentage differs on different browsers
    m

    mammoth-animal-49690

    01/20/2023, 1:05 PM
    I have 39 test cases in one of my project. The point is in Chrome 105, Chromium 109 and Electron 100 39/39 pass. In Edge 105 37/39 passes and 2 fails, finally Firefox 27/39 passes and 12 fails. Any ideas what is happening here?
    g
    t
    • 3
    • 3
  • Is Cypress able to perform such tests?
    s

    sparse-fish-48600

    01/20/2023, 1:26 PM
    I am looking into automation in our small business and I have few use cases. Can you please tell me if it would be possible to achieve using Cypress? 1. Test which would run every 10 minutes, it would check the number of all products available to purchase (see if they have stock >0) and it would save the number. Then after next 10 minutes it would perform new test and check the number again. If the difference is for example > than 5% it would send an email notification. [Scope: we had an issue last week where for some reason our ERP did not parse information about stock and 90% of our products were showing on www as "out of stock"] 2. Test that would go through a shopping process, to see whether it is able to successfully make a new order. If not it would send an email notification. [Scope: to be sure that there isn't a problem with cart/payment and customers can buy items.] 3. Go on few sub pages like:: - /category - /product_detail_page - /cart And see whether they loaded in 100% and in time less than X seconds 4. Any other ideas from your experience that may be beneficiary for a small e-commerce business?
    g
    • 2
    • 3
  • Iterate through a table without unique selector and compare against an array of object
    k

    kind-van-46599

    01/20/2023, 2:11 PM
    Attached the sample html which I have to iterate and validate against the below array of object,
    Copy code
    [
        {
            "title": "Promotion totals by 52 weeks",
            "price": "$2.98",
            "total": "2",
            "h1": "2",
            "h2": "0",
            "forecastEngine": "8,547",
            "forecastAdjust": "10%",
            "scanFunding": "$0.31",
            "brochure": "2",
            "gondola": "2"
        }
    ]
    So far I was able to complete the following code but I'm stuck in terms of constructing a similar array of object while iterating through the elements and comparing it,
    Copy code
    cy.findByTestId('LastYearActualsTable')
        .find('tfoot tr')
        .each(($tr) => {
          const allData = getTexts($tr.find('td'));
        });
    const getTexts = (el: JQuery<HTMLElement>) => {
      return Cypress._.map(el, 'innerText');
    };
    g
    • 2
    • 13
  • How to allow cross origin requests that do not perform navigation (reauthenticate/user token refresh
    a

    astonishing-yak-45049

    01/20/2023, 2:59 PM
    I am using cy.origin as I have to authenticate via a different application before I can use the application under test. This is working fine. However, some requests within the application under test trigger requests to get/update the user token but without navigating back to the authentication application. Currently this means that when such a button is clicked a 401 error is thrown. e.g. when updating the users display name How should this be handled?
  • Cypress test runner crashes on Mac
    w

    witty-yak-10642

    01/20/2023, 5:23 PM
    While running Cypress Test Runner, it consumes 95% or more of the CPU and then crashes within a minute. My system is up-to-date, and installed the latest version of iOS. I found a lot of people with similar problems on Google, but no genuine solutions. It's a blocker for me. My system: MacBook Pro: 2.5 GHz Dual-Core Intel Core i7, 16 GB RAM, macOS Ventura (13.1), Node: v18.13.0, NPM: v 8.19.3, Cypress: 12.3.0
    s
    e
    • 3
    • 8
  • How to pass the current test early & immediately
    b

    broad-engineer-43159

    01/20/2023, 8:24 PM
    So, I`ll declare some example of code ..... cy.request({ url: '', }).then((response) => { if(response.dirCout === 3) { //here I need to mark the test as passed //I believe It is something like Cypress.done() or etc } }) ...... cy.visit() .... cy.get('div.blabla')
  • How can I connect two database in Cypress tests?
    m

    most-processor-2949

    01/20/2023, 10:16 PM
    hello guys 😀 i'm new using cypress.io i'm trying to use two different database because i dont want to use the main database for tests so i would like to make something like main database and the second database for my tests, i'm using mongodb i already have the copy of my main database but now i'm not sure what should i do, i was thinking to open my application in two different ports one for my main application and the second port for my testings with the database for tests but i'm not sure if is the corret way to do or is there another better way ? so what could i do?
    s
    b
    • 3
    • 3
  • How to use Component Testing in NX Angular project
    w

    wonderful-ram-76479

    01/21/2023, 5:44 AM
    Hello! My question may be caused by a fundamental lack of understanding of how Component Testing works, but I've been unable to find clear documentation on this. I'm trying to setup an Angular 15 standalone component for component testing. It was setup in my NX monorepo as a library. I can add a configuration to the project, but I can't get a test to run. I get the following error:
    Copy code
    ts
    const angularJsonPath = await findUp('angular.json', { cwd: projectRoot });
        if (!angularJsonPath) {
            throw new Error(`Could not find angular.json. Looked in ${projectRoot} and up.`);
        }
    Any direction or documentation that I can review to learn more about how to use this correctly would really be appreciated. Thanks!
    w
    o
    • 3
    • 4
  • how do i query results from cypress cloud directly
    t

    thousands-television-13716

    01/22/2023, 8:44 AM
    currently using slack integration but need a way to query test run results directly from cypress cloud
  • Cypress giving me warning on running cypress run
    b

    bright-daybreak-14164

    01/22/2023, 2:43 PM
    Missing baseUrl in compilerOptions. tsconfig-paths will be skipped Warning: We failed to trash the existing run results. This error will not alter the exit code. TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string or an instance of Buffer or URL. Received type boolean (false) at stat (node:fs:1473:10) at Object.e.stat (node:electron/js2c/asar_bundle:5:4651) at Object. (/Users/spyder/Library/Caches/Cypress/10.11.0/Cypress.app/Contents/Resources/app/node_modules/graceful-fs/polyfills.js:309:16) at Object.defineProperty.value [as stat] (/Users/spyder/Library/Caches/Cypress/10.11.0/Cypress.app/Contents/Resources/app/node_modules/fs-extra/node_modules/universalify/index.js:5:57) at Object.tryCatcher (/Users/spyder/Library/Caches/Cypress/10.11.0/Cypress.app/Contents/Resources/app/packages/server/node_modules/bluebird/js/release/util.js:16:23) at Object.ret [as statAsync] (:14:23) at Object.folder (/Users/spyder/Library/Caches/Cypress/10.11.0/Cypress.app/Contents/Resources/app/packages/server/lib/util/trash.js:9:15) at trashAssets (/Users/spyder/Library/Caches/Cypress/10.11.0/Cypress.app/Contents/Resources/app/packages/server/lib/modes/run.js:166:29) at ready (/Users/spyder/Library/Caches/Cypress/10.11.0/Cypress.app/Contents/Resources/app/packages/server/lib/modes/run.js:773:9) Can anyone help me?
    m
    • 2
    • 9
  • Where should this code section be placed, in the cypress.config.js?
    w

    white-mouse-85089

    01/22/2023, 8:48 PM
    The gitreadme doesnt say. I am trying to get HTML reports working with axe. Thanks 🙂 Found it here: https://github.com/lpelypenko/axe-html-reporter const reportHTML = createHtmlReport({ results: rawAxeResults, options: { projectKey: 'I need only raw HTML', doNotCreateReportFile: true, }, }); console.log('reportHTML will have full content of HTML file.'); // suggestion on how to create file by yourself if (!fs.existsSync('build/reports/saveReportHere.html')) { fs.mkdirSync('build/reports', { recursive: true, }); } fs.writeFileSync('build/reports/saveReportHere.html', reportHTML);
    • 1
    • 1
  • Cypress IF plugin causes an error
    i

    incalculable-optician-34338

    01/23/2023, 7:20 AM
    it used to work just fine but at some point test suit where i use cypress-if plugin started to throw an error. When i delete the "import "cypress-if" " line - it works (outside of course parts where i use the plugin in chains). I'm using the latest cypress release.
    h
    • 2
    • 2
  • Hey everyone I want to run 1000 tests in parallel to perform a load test
    s

    straight-pencil-91170

    01/23/2023, 7:43 AM
    Hey everyone I want to run 1000 tests in parallel to perform a load test
    s
    g
    +2
    • 5
    • 8
  • Running on chrome headless is not working
    a

    abundant-engineer-8705

    01/23/2023, 9:44 AM
    Hey everyone, unfortunately I'm not able to run my tests on chrome headless (non-headless works well ) . I'm also using: 'chromeWebSecurity: false' but it has no effect on headless mode. The error that I'm getting is: CypressError: Timed out after waiting
    60000ms
    for your remote page to load. Your page did not fire its
    load
    event within
    60000ms
    . When this
    load
    event occurs, Cypress will continue running commands. Because this error occurred during a
    before each
    hook we are skipping the remaining tests in the current suite:
    My First Test
    Increasing the timeout is not a solution. I also had a look on other threads regarding this issue and it seems that I'm not the only one that has this problem I tried to run the tests on electron and edge and there is no problem but we really want to use chrome. Please let me know what I can do
  • I'm trying to get the index of an element with the latest Cypress
    b

    broad-analyst-94821

    01/23/2023, 12:17 PM
    The previous code worked with v7; v12 it fails with error ```cy.contains(
    .columnTitle
    , colName) .invoke('index') .then(i => { resolve(Number(i)); });
    g
    • 2
    • 2
  • Multi-user test with Windows Authentication
    g

    gray-carpenter-43075

    01/23/2023, 12:21 PM
    Hello. I'm currently evaluating testing tools to find the one best suited to a corporate intranet application I'm developing. I see that the cypress-ntlm-auth plugin can handle the IWA part, but I'm wondering about how I could use Cypress to test multiple user / concurrency scenarios. For example, in my application there is a "check-out" process for certain objects. I want to be able to test what happens when User1 executes a check-out on ObjectA, and then User2 comes along and tries to perform a task using that same object. Can this be accomplished in Cypress considering the single browser restriction?
    e
    • 2
    • 1
  • Measuring the page size (total size of resources in Kb/Mb)
    f

    flaky-napkin-21194

    01/23/2023, 12:37 PM
    Have only been able to measure the total size of the HTML with this function
    document.documentElement.innerHTML.length
    . Does anyone have a better way to measure the entire page size using JavaScript?
    b
    g
    m
    • 4
    • 12
  • How to check that an element doesn’t overlap another element ?
    b

    bumpy-insurance-8581

    01/23/2023, 2:54 PM
    As the title say, how is it possible to do that using Cypress should check ?
    g
    • 2
    • 1
  • Unable to run Test Suite in Chrome (Headed) via command-line
    i

    important-river-13051

    01/23/2023, 3:24 PM
    System is running test in Electron (headless) browser, when executing this command "npm run test --spec \"tests/integration/XYZ.js --headed --browser chrome "
    n
    • 2
    • 4
  • Conditional Usage of Cypress
    n

    narrow-artist-87113

    01/23/2023, 3:56 PM
    I am testing a website, when the user enter the website, two things can happen: 1. User is new, hence, he/she will have to Sign-in with GitHub. 2. If User is not new, hence, he/she will directly land to the main page of website. Now, since, i don't know wether a user is logged in with github or not, how can i test? P.S: I know that i can create different for these two use case, but i want to do it in one file, conditionally, Please help!
    g
    t
    e
    • 4
    • 14
  • I need to test for Safari
    g

    gray-beard-8992

    01/23/2023, 4:04 PM
    I am trying to implement testing on WebKit. My tests run fine on Firefox, Chrome, Edge, and Electron, however for WebKit Cypress can't access the URLs that are accessible through VPN. Is there anything different in setup for VPN for WebKit? I didn't have to do anything specific for other browsers. Can anyone help?
    w
    • 2
    • 2
  • MFA and SSO Login with Cypress.
    f

    future-zebra-76230

    01/23/2023, 5:20 PM
    Hello everyone, I am new to cypress and my first task is to automate the login that is using Microsoft SSO and MFA is on. I did some research but I couldn't find many example about how to do it. I found the following post and try to follow it but I am getting errors. https://spurqlabs.com/login-to-o365-sso-enabled-application-with-mfa-using-cypress-10/ I am using Cypress Version: 11.2.0 Any Idea? Error:
    c
    • 2
    • 1
  • Send a plain request in Cypress
    m

    magnificent-cat-57082

    01/23/2023, 6:14 PM
    I want to send a plain PUT request with the text "none" cy.request({ url:
    ${url}
    , method: 'PUT', headers: { 'Content-Type': 'plain/text', }, }); is what I have so far Body doesn't seem to allow "none". Any ideas?
    • 1
    • 1
  • How do I pass info between spec files
    g

    gray-exabyte-2941

    01/23/2023, 6:44 PM
    Hello everyone, I am new to Cypress so sorry if this is a stupid question with an obvious solution. With that being said how do I pass information between spec files? An example is a login step living in spec file A. I don't want to write the same login step in all my test files if it that step already exists in my "login test file". Is there a way I can call that login step from spec file A into spec B without rewriting the whole step?
    e
    g
    • 3
    • 3
  • Is there any way to extract a cy.readfile data to variables?
    c

    creamy-terabyte-11590

    01/23/2023, 7:37 PM
    I am trying to read the test cases I need to execute from a CSV file in the before hook but when I read the CSV file I only have access to that info withing the cy.readfile scope. As soon as I leave the cy.readfile function I lose the data even when I copy it to another variable. Output: TestCases -> SRTP-T42,SRTP-T55,SRTP-T52,SRTP-T40,SRTP-T51,SRTP-T39,SRTP-T56,SRTP-T50,SRTP-T38,SRTP-T45,SRTP-T47,SRTP-T48,SRTP-T49,SRTP-T44,SRTP-T43,SRTP-T53,SRTP-T46,SRTP-T54,SRTP-T41 TestCases outside -> undefined ------ For some reason when I try to implement external tools/plugins like 'fs' to read the file, I am having issues, I feel like I might not be skilled enough in typescript to be able to debug them so that's why I am trying to use cypress commands.
    g
    e
    • 3
    • 11
  • How can I configure the environment in the allure report?
    t

    thousands-angle-51877

    01/23/2023, 8:38 PM
    Hello Guys, I'm trying to integrate the allure report until the budget is approved. How can I set the environment in the allure report? Thanks in advance!!!
12345...26Latest