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

    cold-doctor-52849

    04/05/2022, 8:51 AM
    Hi! I'm trying to overwrite the visit command with a custom header, but I can't seem to get it to work.. The custom header works fine with cy.request, but I can't seem to get it to work with cy.visit
    Copy code
    Cypress.Commands.overwrite('visit', (originalFn, url, options) => {
        options.headers = {'CYPRESS_TOKEN': token}
        return originalFn(url, options)
    })
    Cannot set properties of undefined (setting 'headers')
    when I add the header option to the plain cy.visit without overwriting anything, I get this:
    Copy code
    The following error originated from your application code, not from Cypress.
    
    > $ is not defined
  • c

    cold-doctor-52849

    04/05/2022, 9:52 AM
    Looks like the current workaround was to modify all requests in a beforeEach hook in the support/index.js file 🙂
    Copy code
    cy.intercept("/**", (req) => {
            req.headers["CYPRESS_TOKEN"] = token
        })
  • b

    better-engineer-26463

    04/05/2022, 11:35 AM
    HI All Best way to implement OAuth2 Google ? Seems like Cypress Documenation ends up not working - Google Authentication documentation followed -> https://docs.cypress.io/guides/testing-strategies/google-authentication#Custom-Command-for-Google-Authentication Error -> cy.loginByGoogleApi is not a function
  • t

    thankful-mechanic-47958

    04/05/2022, 10:02 PM
    Hey everyone! My team and I have been experiencing an issue where a failed test that retries in the cypress dashboard causes the runner in Circle CI to hang, and keeps repeating "1 of 3", then eventually times out. We have opened multiple support issues, tried different versions of Cypress, adjusted settings, and jumped through many other hoops with no luck. We are running 40 tests in parallel so it's a large suite of tests. Sometimes they pass, but most runs it times out. The tests in the dashboard show passing but the runner seems to disconnect from the dashboard so all of our work is in a "failed" state, even if everything is good. Which is making things really difficult for us. I am writing here in hopes that someone has seen this issue before and maybe knows where to look. Feeling desperate...
    Copy code
    Send All
     (Attempt 1 of 3) should show a dialog on selected
     (Attempt 1 of 3) should show a dialog on selected
  • f

    future-eye-56254

    04/06/2022, 9:11 AM
    Hello I am stuck with an uncaught exception that does not show up as an error on the test runner but it also doesn't perform the action. 1. I have a a page where there are checkbox options. On selecting a check box option it adds a paragraph text to an iframe text area right after these checkboxes. 2. But when I do this using Cypress - It checks the checkboxes but does not add the text to the iframe and I see an (uncaught exception) TypeError: Cannot read property '238262DF-914C-44C2-A5EA-A1CC01601A96' of undefined on the Cypress Test Runner I tried the Cypress Recipes to turn off all uncaught exception handling but that didn't help me. Any suggestions are highly appreciated.
  • t

    tall-animal-48628

    04/06/2022, 1:19 PM
    Hi Everyone. Im just new to cypress and got a test suite working locally without any issues. But when we ran it in pipeline(docker). Im getting aborted instance for XHR request. Currently my test is using web form(user name and password then submit) and as part of this is post request in browser(XHR). I tried to increase the timeout to 12 minutes from the default and no lock. I also try to do cy.request(post method to login to validate the connection in docker and its successful). Just wondering if anyone encountered this scenario.
  • b

    better-engineer-26463

    04/06/2022, 8:51 PM
    😮‍💨
  • r

    red-smartphone-4834

    04/07/2022, 7:44 AM
    I will look into that as soon as possible
  • p

    powerful-orange-86819

    04/07/2022, 8:31 AM
    is the iframe in the same domain or is it different domain?
  • p

    powerful-orange-86819

    04/07/2022, 8:34 AM
    I have a custom command that takes the username and password of the user as cy.userLogin(username, password) and inside i call an endpoint which returns access_token that I store in the env to use in different tests , if you are directly logging with all oauth information just add the client_secret, id, scope and grant_type to the env file and use them dinamically from the command, start by hardcoding them in the command and then move to env
    Copy code
    js
    Cypress.Commands.add("userLogin", (username, password) => {
      const env = Cypress.env();
      const options = {
        method: "POST",
        url: env.apiUrl,
        body: {
          username: username,
          password: password,
        },
      };
      cy.request(options).then((response) => {
        env.tokens[`${username}`] = response.body.access_token;
        Cypress.env(env);
      });
    });
  • g

    green-ram-60124

    04/07/2022, 8:39 AM
    ~~Hi people! I have a question regarding gRPC streams and the page load event. Fairly basic example, vitit
    /
    and find the content of an
    h1
    tag. The page opens a few gRPC streams and in Cypress I can see the data being fetched, but the stream POST requests appear loading, never marking resulting in a timeout as the page fails to load completely (which is actually not the case). Does anybody know how to avoid or skip this loading states for the gRPC streams?~~
  • s

    sticky-exabyte-72626

    04/07/2022, 1:40 PM
    Hi guys, does anyone know if I can manually define the done() callback timeout? 🤔
  • g

    green-ram-60124

    04/07/2022, 2:39 PM
    Indeed, I would be interested in the same thing, I get the data, but the gRPC streams stay open and Cypress thinks the page has not finished loading...
  • g

    green-ram-60124

    04/07/2022, 2:41 PM
    you have
    .then(options, callbackFn)
    where you can pass an object to options with the
    timeout
    value.
  • s

    sticky-exabyte-72626

    04/07/2022, 2:45 PM
    you mean
    done().then({ timeout: 2000 })
    ?
  • s

    sticky-exabyte-72626

    04/07/2022, 2:45 PM
    seems like a weird syntax
  • g

    green-boots-72737

    04/08/2022, 2:28 PM
    Does anyone know why this could be happening? When trying to run Cypress in Gitlab CI, it throws this error:
    Copy code
    Your system is missing the dependency: Xvfb
    Install Xvfb and run Cypress again.
    But I am running Cypress from the offical Cypress container
    cypress/base:12
    . (https://hub.docker.com/r/cypress/base) The docs for this say "*Docker images that include all operating system dependencies necessary to run Cypress, but NOT Cypress itself and no pre-installed browsers.*" so how can Xvfb not be installed?
  • s

    stale-orange-69593

    04/08/2022, 10:07 PM
    Hey guys, I am having an issue when logging on a website with cypress the session ends immediately after I logging, then I tried with selenium and the session didn't expired. Tried saving the local and session storage Login via API Saving the cookies Create the local and session storage Setting false the chromeWebSecurity But none of them work any idea what more I could try or why it works as expected on selenium but not cypress?
  • f

    future-eye-56254

    04/09/2022, 10:28 AM
    Its in the same domain
  • f

    future-eye-56254

    04/09/2022, 10:35 AM
    #763105090679865354 Are there ways to mask passwords so we don't expose them in the Cypress.json or inside the spec ? May be like encrypt the passwords(using ps), place it locally(may be inside a file) & when passing this to login form - decrypt and send the actual?
  • p

    proud-room-838

    04/10/2022, 9:17 AM
    I have an issue when using IntelliJ where if I want to jump to implementation of a custom command from my tests, I always end up at the declaration of
    Copy code
    declare namespace Cypress {
      interface Chainable {
    in index.d.ts (see here for reference what I mean https://github.com/cypress-io/cypress-example-recipes/blob/master/examples/fundamentals__add-custom-command-ts/cypress/support/index.d.ts)where I actually want to jump to where the method really is declared in index.d.ts. Any idea how to solve this?
  • p

    powerful-orange-86819

    04/11/2022, 6:43 AM
    I have masked mine in the CI using the local variables where only I have access to them and added the cypress.json / cypress.env.json to gitignore, i think its the best approach security wise
  • f

    future-eye-56254

    04/11/2022, 7:14 AM
    beforeEach(() => { Cypress.Cookies.preserveOnce('cookiename1', 'cookiename2') //Preserves cookies so that the application does not logout between each test block })
  • p

    purple-action-61464

    04/11/2022, 7:43 AM
    Does some ever occur this error?
  • p

    purple-action-61464

    04/11/2022, 8:01 AM
    Ok, I solved this: https://www.cypress.io/blog/2021/01/20/running-cypress-on-the-apple-m1-silicon-arm-architecture-using-rosetta-2/
  • f

    fancy-laptop-20632

    04/11/2022, 8:09 AM
    Can anyone help me out why this problem occurs. describe('My Hook Test',()=>{ let data; before(function (){ cy.fixture('example').then(function(users){ data=users return data }) }) it('My First hook Test', ()=>{ cy.visit('https://rahulshettyacademy.com/angularpractice/') cy.wait(1000) cy.get(':nth-child(1) > .form-control').type(data.name) cy.get(':nth-child(1) > .form-control').should('have.attr','minlength',2) cy.wait(1000) cy.get(':nth-child(4) > .ng-untouched').should('have.value',data.name) cy.get('input[name="email"]').type(data.email) cy.wait(1000) cy.get('#exampleInputPassword1').type(data.password) cy.get('select').select(data.gender) cy.get('#inlineRadio3').should('be.disabled') cy.get(':nth-child(2) > .nav-link').click() cy.get('h4.card.title').each($el,index,list); { if($el.text().includes('Blackberry')) { cy.get('button.btn btn-info').eq(index).click() } } }) })
  • g

    gray-kilobyte-89541

    04/11/2022, 10:38 AM
    you are doing https://on.cypress.io/conditional-testing which you have to be careful how you do, see https://glebbahmutov.com/cypress-examples/9.5.0/recipes/conditional-testing.html#conditional-testing
  • n

    numerous-kangaroo-93739

    04/11/2022, 2:17 PM
    Good day, When I try to use the cypress.cookies.default command in the support index.js i am getting this error (see image). Does anyone know why this would be triggered?
  • s

    stale-orange-69593

    04/11/2022, 2:23 PM
    Thanks you for the response, but in this case it didn't work the session gets terminated on cypress before the cookies are generate.
  • m

    magnificent-finland-58048

    04/11/2022, 3:13 PM
    that's what cypress.env.json is for effectively it's dotenv for cypress stuff. You gitignore the file, and create CI env vars, or you an have local env vars without any cypress.env.json file. https://docs.cypress.io/guides/guides/environment-variables#Option-2-cypress-env-json
1...545556...252Latest