https://cypress.io logo
Join Discord
Powered by
# e2e-testing
  • h

    happy-dinner-13480

    11/17/2022, 2:57 PM
    I'm testing if my users can login:
    Copy code
    typescript
    cy.el('inputEmailAddress').type(Cypress.env('CUSTOM_EMAIL'));
    cy.el('inputPassword').type(Cypress.env('CUSTOM_PASSWORD'));
    cy.el('buttonLogin').click();
    locally this is fine, but on my CI sometimes the second field isn't filled in. Adding some waits seems to fix it:
    Copy code
    typescript
    cy.el('inputEmailAddress').type(Cypress.env('CUSTOM_EMAIL'));
    cy.wait(500);
    cy.el('inputPassword').type(Cypress.env('CUSTOM_PASSWORD'));
    cy.wait(500);
    cy.el('buttonLogin').click();
    has anyone else experience this issue with typing multiple inputs in a row?
  • a

    acceptable-fall-11897

    11/17/2022, 3:14 PM
    @gray-kilobyte-89541 Hello I am trying to connect MongoDB with cypress for delete some data. Please help me how can I do
  • f

    fresh-doctor-14925

    11/17/2022, 3:16 PM
    Have you read his blog?https://glebbahmutov.com/blog/testing-mongo-with-cypress/
  • a

    acceptable-fall-11897

    11/17/2022, 3:20 PM
    I try this but unable to connect may be small error but unable to find. I am new.
  • g

    gray-kilobyte-89541

    11/17/2022, 4:42 PM
    I have added a new lesson "Lesson g1: Visit every page using the links found on the page" to my course https://cypress.tips/courses/cypress-plugins and just for you I made it free 🙂
  • l

    late-quill-17187

    11/17/2022, 4:44 PM
    Thanks
  • p

    plain-elephant-20908

    11/17/2022, 6:32 PM
    Hi here, Is there a way to point a custom e2e.js file e.g.
    customeE2E.js
    under` /support` folder? for cypress run
  • b

    broad-lock-59143

    11/17/2022, 6:53 PM
    Hello everybody, I am looking to run Cypress tests through GitHub actions on multiple browsers. For whatever reason, tests on Edge, Webkit, and Chrome using cy.request() timeout and fail when trying to access our server. Tests on Electron and Firefox are successful. It is worth noting that all these tests pass when run locally on the Cypress web app. Would anyone be able to provide insight on what may be causing this issue? Thank you in advance
  • e

    enough-truck-68085

    11/17/2022, 6:56 PM
    "cypress run --e2e --config supportFile=cypress/support/customE2E.js"
    you can always change the support file location for e2e if needed https://docs.cypress.io/guides/references/configuration#e2e
  • w

    worried-pager-99039

    11/17/2022, 7:55 PM
    Hey, I am starting to introduce Cypress to our company and am writing the first e2e tests right now. We are using a CookieBanner from CodeCentric which I would like to disable programatically. Working with
    cypress open
    and having an actual browser where the test runs the following code is working:
    Copy code
    ts
    beforeEach(() => {
        Cypress.on("window:before:load", (window) => {
        window.localStorage.setItem("some_key", "some_value")
        window.localStorage.setItem("another_key", "another_value");
      })
    })
    But running this with
    cypress run --headless --browser electron
    does not work and it seems like that the items are not set inside
    localStorage
    . I tried to check it with
    Copy code
    ts
    expect(localStorage.getItem("some_key")).to.not.be.null;
    expect(localStorage.getItem("another_key")).to.not.be.null;
    Is there a way to set some
    localStorage
    items in the headless mode to get rid of my cookie banner?
  • f

    fresh-doctor-14925

    11/17/2022, 8:21 PM
    I think you might be overcomplicating things with the
    window:before:load
    . Have you tried doing a
    cy.setCookie()
    in your
    beforeEach()
    before your
    visit()
    command?
  • w

    worried-pager-99039

    11/17/2022, 8:33 PM
    No, did not try it yet. Unfortunately they are not checking cookies but some entries in the localStorage.
  • w

    worried-pager-99039

    11/17/2022, 8:36 PM
    So unfortunately this does not help me 😦
  • m

    mysterious-belgium-25713

    11/17/2022, 8:50 PM
    And if you try it a bit different so not using window before load but using cypress window
    Copy code
    js
    cy.window().then((win) => {
      win.localStorage.setItem("some_key", "some_value")
      win.localStorage.setItem("another_key", "another_value");
    })
  • m

    mysterious-belgium-25713

    11/17/2022, 8:52 PM
    If that doesnt work, there is a plug called localstorage commands. Never used it before but it might help.
  • m

    mysterious-belgium-25713

    11/17/2022, 8:52 PM
    https://www.npmjs.com/package/cypress-localstorage-commands
  • s

    square-honey-48197

    11/17/2022, 8:56 PM
    anyone experience a dropdown that can't be clicked headlessly with electron, but can be clicked just fine headed? racking my brain trying to find a workaround
  • m

    mysterious-belgium-25713

    11/17/2022, 9:29 PM
    How do you click in your dropdown. Are you using cy.select()?
  • m

    mysterious-belgium-25713

    11/17/2022, 9:30 PM
    Or is it not a real dropdown?
  • s

    square-honey-48197

    11/17/2022, 9:30 PM
    it's one of those "fake" dropdowns that uses
    cdk-overlay-container
    Headed it works fine, but headlessly it fails to click as the dropdown elements are detached from DOM
  • s

    square-honey-48197

    11/17/2022, 9:31 PM
    Each of the
    span
    elements is the desired element to click.
    Copy code
    Javascript
    cy.get('span').contains('WF+ AVOD').click()
  • w

    worried-pager-99039

    11/17/2022, 9:32 PM
    Did not know about this method. It kinda helped... unfortunately the cookie banner appears on the next page again. Will just disable it on the testing instance. Thanks for your help
  • s

    square-honey-48197

    11/17/2022, 9:33 PM
    Cypress
    complains that the
    span
    element is detached from DOM at or before the
    .contains()
    but only when running headlessly
  • s

    square-honey-48197

    11/17/2022, 9:40 PM
    @mysterious-belgium-25713 do you have any ideas? 🙂
  • m

    mysterious-belgium-25713

    11/17/2022, 9:45 PM
    will it give a different result if you would do
    Copy code
    js
    cy.contains(".mat-option-text","WF+ AVOD").click()
  • s

    square-honey-48197

    11/17/2022, 9:45 PM
    just tried that, still
    detached from DOM
    only headlessly, works fine headed (Electron 106) for both
  • s

    square-honey-48197

    11/17/2022, 9:46 PM
    i also checked, there's no network calls being made when I click to open the dropdown, so there's nothing to wait/ guard
  • m

    mysterious-belgium-25713

    11/17/2022, 9:46 PM
    And what if you would try to do headless with chrome and see if that yields a different result
  • s

    square-honey-48197

    11/17/2022, 9:47 PM
    npx cypress run --browser chrome
    ? or do I need to specify the path to the chrome binary?
  • m

    mysterious-belgium-25713

    11/17/2022, 9:47 PM
    just like that
1...145146147...192Latest