https://cypress.io logo
Join Discord
Powered by
# i-need-help
  • cypress exists after one Get request
    f

    flat-addition-70667

    05/15/2023, 10:26 PM
    Hi Group, I am one month new to cypress. My first cypress E2E scripts succeeded on login step which using an external url to authorize login user, but failed on clicking step on our application dashboard which is supposed to open a new page. The cypress log in VS code terminal shows one of the requests after clicking failed (#401) GET /api/auth-service/v1/user/current/user 401 83.391 ms - - and followed by GET /logout 200 98.970 ms - - I verified the application session storage before this clicking step inside cypress chrome, which contains all the information in the real chrome browser at the same step, including access token. I am wondering how to debug further to find what caused this Get request failed. Thanks, Cheng
    • 1
    • 3
  • Drag and Drop is not working.
    a

    adventurous-whale-33899

    05/16/2023, 5:44 AM
    Hi, I am trying to drag and drop elements from one div to other on https://letcode.in/sortable . So far i have tried "cypress-drag-drop' and 'cypress-real-events' plugins as well.
    Copy code
    cy.get("#cdk-drop-list-0 div:first-child").drag("#cdk-drop-list-1", {force: true})
    Copy code
    cy.get('#cdk-drop-list-0 div:first-child').realMouseDown({ button: "left" })
    cy.get("#cdk-drop-list-1").realMouseMove(50, 50, { position: "center" })
    cy.get("#cdk-drop-list-1").realMouseUp(50, 50, { position: "center" })
    Copy code
    cy.get("#cdk-drop-list-0 div:first-child")
                .trigger("mousedown", { button: 0, force: true })
                .trigger("mousemove", 48, 586, { force: true })
                .trigger("mouseup", 48, 586, { force: true })
        })
    On the debug window i can see the element being dragged but will not be dropped.
    e
    s
    p
    • 4
    • 6
  • cy.visit in incognito mode stops working
    b

    billowy-petabyte-65450

    05/16/2023, 10:50 AM
    I need to visit an URL in incognito mode inside a test, and I developed this solution cy.visit(link, { chromeWebSecurity: false, browser: 'chrome', incognito: true }); it was working for me during a time, but it doesn't work right now. (i would like to finde a solution independent of in what browser is the framework running)
  • config file crashed
    s

    stocky-grass-9933

    05/16/2023, 2:18 PM
    Anyone familiar with this?

    https://cdn.discordapp.com/attachments/1108035631130607807/1108035631449391214/image.png▾

    • 1
    • 1
  • Cypress install fails. Downloaded file crashes on clicking
    s

    silly-egg-91335

    05/16/2023, 3:21 PM
    Downloaded cypress.zip file from cypress.io and tried to install. When I click on the cypress.zip file it just crashes out. No error messages or windows. Need help getting Cypress installed.
    m
    • 2
    • 3
  • How to access iframe document when iframe - contentDocument is null?
    s

    square-toothbrush-32850

    05/16/2023, 6:16 PM
    The site has an iframe and I can't access by cypress any of its content. Tried some guides but found no solution. Any help?
    s
    • 2
    • 3
  • how do you capture numbers in cypress.
    p

    proud-answer-20715

    05/16/2023, 11:13 PM
    Trying to capture a (dynamic numbers) means whenever I run the application I get new numbers. This is what I am doing cy.get("#numb").invoke('text).then(text => { numbers = parseInt(text). I keep getting NaN when I log it
    l
    • 2
    • 2
  • addQuery: How does it work?
    p

    purple-hairdresser-80317

    05/17/2023, 1:19 AM
    Hey, i'm currently using PrimeNG, and I wanted to write customQueries to select certain components. Also i'm using @testing-library/cypress. I've tried multiple different variant and searched for hours for explanations or good examples, which could help me understand what i'm doing wrong. Currently the (not working) implementation looks like this:
    Copy code
    Cypress.Commands.addQuery('findPrimeNgDialog', function(header) {
      return subject => subject.findByRole('dialog')
    })
    I have to use the subject, as I cannot just
    return subject => cy.findByRole('dialog')
    . So, when I try to call the query, similar to
    cy.get()
    , like this
    cy.getPrimeNgDialog('HeaderText').as('Dialog')
    , I expected it to work like
    get()
    , however
    subject
    is undefined. However calling it with
    cy.get('body').getPrimeNgDialog('HeaderText').as('Dialog')
    results in getting a
    jquery.fn.init
    object, but I don't really know what to do with that object. I thought I could simply chain the queries together, but it does not work. Sadly, I haven't found much information or examples about addQuery, therefore I really don't know what to try next. I'm fairly certain I misunderstood how addQuery is supposed to work, can someone explain this to me, or point to a ressource where I could learn more about that? The only thing I got to work is
    Copy code
    Cypress.Commands.addQuery('findPrimeNgDialog', function(header) {
      const getFn = cy.now('contains', '[role="dialog"]', header) as any
      return subject => getFn(subject) // However not chainable inside here
    })
    But since
    cy.now()
    is not chainable, therefore I have to use
    contains
    instead of
    get
    to be able to search for the text inside. And at this point i'm questioning myself, if what i'm trying is actually meaningful.
    g
    • 2
    • 10
  • Cypress login via WIA + ADFS
    c

    clever-night-39043

    05/17/2023, 1:53 AM
    Hi my current project is using Windows Integrated Authentication (WIA) with Active Directory Federation Services (AD FS) to log in. The browser will show a system dialogue to ask for windows credentials, so it seems to be out of browser automation scope. Is it possible to achieve this by Cypress? Thank you very much.
    c
    • 2
    • 2
  • cy.visit() failed frequently.
    r

    rich-pharmacist-74804

    05/17/2023, 7:22 AM
    I have 2 Applications with the same domain. I set the main URL to
    baseUrl
    in cypress.config.js and another URL to
    env
    as
    url
    . For some reason, I have to visit
    cy.visit('url')
    . However, frequently it fails to load and throws an error as
    Timed out retrying after 15000ms
    . I added a
    debug()
    but it's empty.
    cy.visit('/') - (baseUrl)
    works very well and
    cy.visit('url')
    also works sometimes. Did anyone face such error?
    • 1
    • 1
  • callback hell
    i

    important-noon-13871

    05/17/2023, 8:35 AM
    Any better way to avoid callback hell for .then ?
    Copy code
    let count = {
      interest: 0,
    };
    
    cy.fixture('campaign_interest.json').then((mockAPIInterest) => {
      cy.fixture('campaign_interest_empty.json').then((mockEmptyAPIInterest) => {
        cy.intercept('GET', '/api/v2/dmp-light/campaign/interest/default*', (req) => {
          count.interest++;
          if (count.interest <= 1) {
            req.reply({
              statusCode: 200,
              body: [mockAPIInterest]
            });
          } else {
            req.reply({
              statusCode: 200,
              body: [mockEmptyAPIInterest],
            });
          }
        }).as('getInterest');
      });
    });
    g
    • 2
    • 1
  • cy.tick() doesn't work. Anything else I can use that works on 'moment'?
    s

    steep-furniture-84934

    05/17/2023, 11:11 AM
    I am following along with Gleb Bahmutov's course on cypress on the website blazemeter.com. There he shows how the cy.clock and cy.tick commands work. But I think that the sudoku app has changed since he did the video because it doesn't work the same anymore. I think that cy.tick doesn't work when the app uses the 'moment' dependency to set the timer. Is there anything else I can use in order to set the timer to a specific value.
    g
    • 2
    • 8
  • Request Interception: Multiple Requests to one GQL endpoint. Wait until all requests are done
    f

    fresh-van-73810

    05/17/2023, 11:20 AM
    Hey! I just ran into following issue: I wait for my fetch requests to finish (multiple ones to the same graphql endpoint). But i now have a case where my wait does not see any intercepted calls left therefore skips. This is because my request seems to be sent about a second after the click. Cypress continues and expects an element which is not fetched yet. I can have an arbitrary wait and then wait for my request to finish. But i really don't like that ^^'. The attached screenshot shows the case with the one second wait to give a concrete example. I'd appreciate any help ! Best Regards Jonas

    https://cdn.discordapp.com/attachments/1108353364288348191/1108353364393214082/Bildschirmfoto_2023-05-17_um_13.17.19.png▾

    • 1
    • 2
  • Hello, is there any command to return list of all cypress custom commands?
    s

    shy-park-96196

    05/17/2023, 1:22 PM
    I need to get list of all custom commands which defined by a user in cypress
    • 1
    • 2
  • POM parameter not working
    a

    able-twilight-99822

    05/17/2023, 2:26 PM
    `// testFile.js import { When } from 'cypress-cucumber-preprocessor/steps'; import { adminPageDefinitions } from './adminPageDefinitions'; When('I select the {string} Menu', (sideMenu) => { adminPageDefinitions.selectMenu(sideMenu); }); // adminPageDefinitions.js import adminPage from './adminPage'; export const adminPageDefinitions = { selectMenu(sideMenu) { cy.get(adminPage.pageElements.sideMenu(sideMenu)) .should('be.visible') .click(); }, }; // adminPage.js const adminPage = { pageElements: { sideMenu(sideMenu) { return cy.get(
    [label="${sideMenu}"]
    ); }, }, }; export default adminPage; `
  • Unable to Select Menu Item in Cypress Test
    a

    able-twilight-99822

    05/17/2023, 2:34 PM
    Description: When attempting to select the menu item 'Admin' using the Cypress test, the following error occurs: Error: Timed out retrying after 10000ms: Cannot read properties of undefined (reading 'toLowerCase') Steps to Reproduce: 1. Run the Cypress test with the scenario 'When I select the "Admin" Menu'. 2. Observe the Cypress Test Runner GUI. Expected Result: The menu item 'Admin' should be successfully selected without any errors. Actual Result: The test fails with a timeout error, indicating that properties of undefined cannot be read. This issue occurs when trying to locate the menu item element using the
    [label="Admin"]
    selector. Additional Information: - The relevant code snippet used to select the menu item is as follows: testFile.js
    Copy code
    javascript
    import { When } from 'cypress-cucumber-preprocessor/steps';
    import { adminPageDefinitions } from './adminPageDefinitions';
    
    When('I select the {string} Menu', (sideMenu) => {
      adminPageDefinitions.selectMenu(sideMenu);
    });
    adminPageDefinitions.js
    Copy code
    javascript
    import adminPage from './adminPage';
    
    export const adminPageDefinitions = {
      selectMenu(sideMenu) {
        cy.get(adminPage.pageElements.sideMenu(sideMenu))
          .should('be.visible')
          .click();
      },
    };
    adminPage.js
    Copy code
    javascript
    const adminPage = {
      pageElements: {
        sideMenu(sideMenu) {
          return cy.get(`[label="${sideMenu}"]`);
        },
      },
    };
    
    export default adminPage;
    - The error occurs at the line
    cy.get(adminPage.pageElements.sideMenu(sideMenu)).should('be.visible').click();
    in the
    adminPageDefinitions.js
    file. - The error suggests that the
    sideMenu
    parameter is undefined or does not match any elements on the page. - Manually inspecting the page confirms that the menu item with the label "Admin" exists and is visible. - The timeout error indicates that the menu item is not being located within the specified timeframe.
  • HELP - How to avoid cypress coverage to reset before each test ?
    b

    bumpy-insurance-8581

    05/17/2023, 2:34 PM
    Hello, on the before all step, cypress-coverage reset the coverage on each test executed. How is it possible to don’t reset coverage but add on the current coverage to see the coverage of all test instead of just one test ? Here is the step that, I think, is the problem but I don’t know how to stop it

    https://cdn.discordapp.com/attachments/1108402084925149235/1108402085269090384/IMG_4181.png▾

    m
    • 2
    • 2
  • Couldn't find tsconfig.json. tsconfig-paths will be skipped
    d

    delightful-magician-24840

    05/17/2023, 3:00 PM
    Hey, I amtrying to implement cypress e2e testing in my angular project but while trying i have a problem with getting it started, i keep getting errors but i do not understand. I am new at cypress testing Couldn't find tsconfig.json. tsconfig-paths will be skipped
    Copy code
    ts
    //tsconfig.json from screen
    {
      "compilerOptions": {
        "module": "system",
        "noImplicitAny": true,
        "removeComments": true,
        "preserveConstEnums": true,
        "outFile": "../../built/local/tsc.js",
        "sourceMap": true
      },
      "include": ["src/**/*"],
      "exclude": ["node_modules", "**/*.spec.ts"]
    }

    https://cdn.discordapp.com/attachments/1108408611404775545/1108408611631276032/image.png▾

    https://cdn.discordapp.com/attachments/1108408611404775545/1108408611937472542/image.png▾

    f
    • 2
    • 11
  • e2e - Login okta
    c

    calm-cartoon-89224

    05/17/2023, 3:18 PM
    Hi, I am trying to perform some e2e tests. I have to access a web application, and it redirects me to the okta login, I type user and password and click on the login button. When I do this it should redirect me again to my web application, but it does not. What it does is to return to the okta login. This does not happen manually, and using selenium either. How can I fix it? Thanks
    b
    • 2
    • 3
  • cy.origin() error
    b

    busy-tailor-13324

    05/17/2023, 10:10 PM
    Following the example in https://docs.cypress.io/guides/end-to-end-testing/okta-authentication#Login-with-cyorigin I add the following to my beforeEach cy.visit("/"); cy.origin("https://my-identity-provider-url", () => { cy.log("got here"); }); I get the following error: cy.origin() requires that the first argument to be a different domain than top. You passed https://my-identity-provider-url to the origin command, The app is set up so that when any protected route is visited it redirects to Okta's login UI at the provided URL. The root is visited and redirects to Okta's UI and then the origin command is passed the same URL in the first param. The strange thing is that this used to work. Thanks in advance.
  • Inability to Select Menu Item in Cypress Test due to POM Parameterisation Limitation
    a

    able-twilight-99822

    05/18/2023, 9:45 AM
    When attempting to navigate to the Admin levels by selecting the 'Admin' menu item using the Cypress test, the following error occurs: "Timed out retrying after 10000ms: Cannot read properties of undefined (reading 'toLowerCase')". This issue is believed to be caused by a limitation encountered when trying to parametrize the string value from the BDD step down to the page element in the Cypress test. Steps to Reproduce: 1. Run the Cypress test with the following feature scenario:
    Copy code
    Feature: Admin Menu Navigation
    
         Scenario: Navigate to the Admin Levels
           When I select the 'Admin' Menu
    2. Observe the Cypress Test Runner GUI. Expected Result: The 'Admin' menu item should be successfully selected without any errors, allowing navigation to the Admin levels. Actual Result: The test fails with a timeout error, indicating that properties of undefined cannot be read. This issue occurs when trying to locate the 'Admin' menu item using the
    [label="Admin"]
    selector. Additional Information: - The test code consists of the following files: - **testFile.js**:
    Copy code
    javascript
        When('I select the {string} Menu', (sideMenu) => {
          adminPageDefinitions.selectMenu(sideMenu);
        });
    - **adminPageDefinitions.js**:
    Copy code
    javascript
        import adminPage from './adminPage';
    
        export const adminPageDefinitions = {
          selectMenu(sideMenu) {
            cy.get(adminPage.pageElements.sideMenu(sideMenu))
              .should('be.visible')
              .click();
          },
        };
    - **adminPage.js**:
    Copy code
    javascript
        const adminPage = {
          pageElements: {
            sideMenu(sideMenu) {
              return cy.get(`[label="${sideMenu}"]`);
            },
          },
        };
    - The error occurs at the line
    cy.get(adminPage.pageElements.sideMenu(sideMenu)).should('be.visible').click();
    in the
    adminPageDefinitions.js
    file. - Manually inspecting the page confirms that the menu item with the label "Admin" exists and is visible.
  • Slide a button
    p

    plain-potato-68806

    05/18/2023, 10:04 AM
    I wanted to slide the below mention button? Is there any better mechanism? I tried something like:
    Copy code
    javascript
              cy.get('#sliderButton > button')
                .trigger('mousedown', { button: 0, position: 'center' })
                .trigger('mousemove', { clientX: 1000, clientY: 0 })
                .trigger('mouseup', { force: true });

    https://cdn.discordapp.com/attachments/1108696607832158329/1108696608012505088/Screenshot_2023-05-18_at_10.59.40.png▾

    a
    g
    • 3
    • 10
  • Best Practices: Duplicate test steps
    f

    flaky-gold-17986

    05/18/2023, 10:40 AM
    What’s the best way to handle tests that have duplicate steps?
    p
    a
    +3
    • 6
    • 7
  • I need to retrieve different baseUrl from different config files.
    f

    full-helmet-93291

    05/18/2023, 1:23 PM
    Hi! A friend of mine came across this situation: 1. Having multiple config.ts files to store different configurations for different environments and apps 2. Needing to retrieve the baseUrl of a specific config file for a particular test. https://stackoverflow.com/questions/76276112/how-do-i-call-my-baseurl-when-i-have-multiple-configuration-files-in-cypress We couldn't find a way to do this. Any ideas?
    l
    • 2
    • 3
  • 12.12.0 introduced issues with self signed certificates in chain for connection with dashboard api
    f

    fast-branch-64525

    05/18/2023, 2:40 PM
    Issue while running the scripts with record key in dashboard API. It was working fine with 10.11.0 version, facing issue after upgrading it to 12.12.0 version. Below is the error message. We encountered an unexpected error communicating with our servers. RequestError: Error: self signed certificate in certificate chain
  • Copy /Paste into doc or file
    f

    fierce-intern-71272

    05/18/2023, 2:59 PM
    I need to build a script that will click a URL, copy text, and then paste that into the Google Doc table (column A would be the links we are clicking, and Column B the text we are pasting for each link). OR if there is an easier way to paste them somewhere and make them readable
  • how can I test these functions
    n

    nutritious-article-48038

    05/19/2023, 3:09 PM
    I am using expo image picker and can't figure out how I can test theses functions?

    https://cdn.discordapp.com/attachments/1109135709807329371/1109135709937340456/Capture.PNG▾

  • The body of iframe is not displayed inside Cypress Test Runner
    f

    flat-addition-70667

    05/19/2023, 4:43 PM
    Hi Group, Inside our application, there is a big sub-application is embedded within an iframe. Although I may use the work-around to get the body of iframe, the UI page inside Cypress Test Runner just show "iframe placeholder for...". Is there a way to show the content of iframe on Cypress browser? If not, how can I debug and verify the test steps on the sub-application which is pretty complicated? through pure Javascript code? Thanks, Katherine
  • Cypress runner - Chrome
    b

    best-dog-89508

    05/19/2023, 4:49 PM
    Hello, I'm getting this error when I run my tests with other browsers, besides Electron, I did search for a fix but no success until now. Did anybody face similar issues?

    https://cdn.discordapp.com/attachments/1109160794505084989/1109160794635129003/image.png▾

  • Using Cypress With MongoDB
    c

    chilly-truck-14848

    05/19/2023, 7:36 PM
    Does anyone have experience in the use of cypress with mongodb? I need to delete a document from the db collections. The configuration i made inside the index.js file is causing an error with tests not loading.
    g
    • 2
    • 2
1...2223242526Latest