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

    stale-optician-85950

    08/24/2022, 1:29 PM
    I would try setting
    followRedirect: false,
    in your POST and ensuring you get a 302, and in a
    .then()
    response make your next request, most likely a GET. Similar to these docs https://docs.cypress.io/api/commands/request#Request-a-page-while-disabling-auto-redirect
  • h

    hallowed-lighter-4305

    08/24/2022, 2:02 PM
    @melodic-ocean-83158 Hi Mario, how are you? Excuse me, I was going to ask you something. in the code that you sent me to have credentials by environment, how can this code be modified so that it works if I have an environment (prod, dev and qa) . { "user": {}, "environment": "prod", "userProd" : { "username": "username", "password": "XXXXXXX" }, "userDev": { "username": "username", "password": "Prosegur2022$" } }
  • i

    icy-television-77938

    08/24/2022, 2:09 PM
    Hello my name is Ambrose. I have been using cypress to automate my application. I recently ran into and issue. I was automating an application that was on the dev environment that required a password to access . I was able to access the application manually, but when it comes time to automate the application on cypress. Cypress stated that it can not access the application giving the URL for the Dev environment. My question is, what approach should I take to solve this issue, working in the Dev environment. What syntax can i write to enable cypress to go through the password face in order to access into the application ?
  • i

    icy-television-77938

    08/24/2022, 2:09 PM
    This is the Example of what I am experiencing
  • s

    stale-optician-85950

    08/24/2022, 2:21 PM
    Create a file under fixtures like
    /fixtures/env-data.json
    with json structure using an object for each environment, such as:
    Copy code
    {
      "environments": [
        {
          "dev": [
            {
              "username": "mrdev",
              "password": "sjkdhdskfhaks$"
            }
          ]
        },
        {
          "qa": [
            {
              "username": "mrsqa",
              "password": "ahsgdshgsa$"
            }
          ]
        },
        {
          "prod": [
            {
              "username": "misterprod",
              "password": "asdiuayeg"
            }
          ]
        }
      ]
    }
    Depending on how you want to use the json data, there are different ways to require and import the json. But you can start with these docs https://docs.cypress.io/api/commands/fixture i.e.
    cy.fixture('env-data').as('data');
  • m

    melodic-egg-83620

    08/24/2022, 2:30 PM
    How do you get Cypress, using Webpack internally, to compile
    import.meta.env
    into
    process.env
    when using Vite instead of webpack for your project bundler? I can't run any E2E tests because Cypress fails to read any
    import.meta.env
    ENV variables and believes it's a syntax error.
  • h

    hallowed-lighter-4305

    08/24/2022, 2:41 PM
    Hi! @stale-optician-85950 Thanks for your comments, I was reviewing it but I don't understand it well, I'm new to this framework. and I don't know how to do the implementation in the spec and how to do the conditional to ask for each environment. I was also reviewing how I can implement it from the commands.js
  • g

    gentle-yacht-17399

    08/24/2022, 3:22 PM
    Hmmm, I just asked a question and the message seems to have disappeared. I'm running into a session cookie issue on a multi-container/domain setup where I have a Rails application running on the build container and a service container running the Frontend application. From the build perspective, the backend is running on http://localhost:3000 and the frontend is running on http://frontend:3002. I have an e2e that is essentially "Log in and see some protected content" that is working fine for me locally. I'm using the experimentalSessionAndOrigin features to deal with the origin changing after login since the login page is on the rails application and the user is redirected to the frontend application. On CI, the session cookie is created with SameSite=Lax and CORS is setup properly. I have a working cucumber test suite with this exact same setup in CI. Does anyone know if there Is something additional I need to configure for this setup with Cypress?
    f
    • 2
    • 3
  • f

    fierce-intern-71272

    08/24/2022, 4:19 PM
    I am trying to click on this text field ,any suggestions please ? thank you <div class=" text-inherit relative h-12 inline-flex items-stretch justify-center border-l-brand-input-width border-r-brand-input-width border-t-brand-input-width border-b-brand-input-bottom-width rounded-t-brand-input-top rounded-b-brand-input-bottom w-full bg-white border-input-primary
  • f

    fancy-match-96032

    08/24/2022, 4:45 PM
    an approach could be to use environment variables set in your CI provider on the command-line and read them with
    Cypress.env
    -- especially if you want to have production credentials https://docs.cypress.io/api/cypress-api/env#Name https://docs.cypress.io/guides/guides/environment-variables
  • h

    hallowed-lighter-4305

    08/24/2022, 5:04 PM
    thanks @fancy-match-96032 yes, I have already reviewed this documentation, I have implemented some things but they have not worked for me, I am new to this topic and I cannot understand many things. I also have version 10 of cypress and I don't see many step-by-step examples of how to do it. If you have an example it would be great. thank you for your comments.
  • c

    chilly-quill-34099

    08/24/2022, 5:39 PM
    Hi there, I am new to e2e-testing and I am currently figuring out how to stay logged in (via Azure AD) while doing several tests. The login logic itself is working fine (I used parts of this repo: https://github.com/juunas11/AzureAdUiTestAutomation). My
    cy.loginWithApiCall()
    -function is creating several items in the local storage, which than is being used by the website to authenticate the user. The problem which I am facing is with sessions: Currently I have to login for every test, which might lead to a lock down of the account (because of to many calls in a certain period). I would prefer to stay logged in, if that is possible, but have separate tests (
    it('test1'), ...
    ). Is that possible, or is it prevented by design to have isolated tests?
    Copy code
    ts
    /// <reference types="cypress" />
    
    describe('Dashboard', () => {
    
      it('login via RPOC works correctly', () => {
        cy.session('mySession', () => {
          cy.loginWithApiCall(); //👈call for each test
          cy.visit('/').url().should('include', '/portal');
        });
      });
    
      it('"Welcome" is visible', () => {
        cy.session('mySession', () => {
          cy.loginWithApiCall(); //👈call for each test
          cy.visit('/portal').contains('Welcome');
        });
      });
    });
    The strange part is, that the
    cy.beforeEach()
    function does not work as well (Is it because it is outside the session?). I would think, that I could reuse a session with the same ID, but I guess this is isolated for each
    it()
    function?
  • m

    melodic-ocean-83158

    08/24/2022, 5:57 PM
    this should work for you:
  • m

    melodic-ocean-83158

    08/24/2022, 5:58 PM
    Copy code
    {
      "user": {},
      "environment": "prod",
      "userProd": {
        "username": "username",
        "password": "XXXXXXX"
      },
      "userDev": {
        "username": "username",
        "password": "DEVpass"
      },
      "userQA": {
        "username": "username",
        "password": "QApass$"
      }
    }
  • h

    hallowed-lighter-4305

    08/24/2022, 6:09 PM
    Okay! Perfect @melodic-ocean-83158 , thank you very much. but I have a doubt, with the environment variable. Is it necessary that it also have the value of "Pre" and Dev.? since in the spec. is evaluated for prod. I mean this way. if (Cypress.env('enviroment') === "prod) { Cypress.env('user', Cypress.env('userProd')) }
  • f

    fancy-match-96032

    08/24/2022, 6:23 PM
    session isn't isolated to
    it()
    -- the purpose of
    cy.session
    is to avoid having to log in for every test. local storage should just get restored as long as you use the same id (in your case
    mySession
    ). can you paste your
    loginWithApiCall
    code?
  • c

    chilly-quill-34099

    08/24/2022, 6:42 PM
    It is basically in https://github.dev/juunas11/AzureAdUiTestAutomation. My POST request is just a bit different and converted into TypeScript. You can have look into
    UiTestAutomation.Cypress/cypress/support/auth.js
    there you can find the
    login()
    -function which is basically my function
    loginWithApiCall()
    with all its dependencies.
  • c

    chilly-quill-34099

    08/24/2022, 6:46 PM
    So according to your statement my second
    cy.loginWithApiCall()
    -call (in Welcome is visible)should be unnecessary, but if I delete the statement, the visit is not working, because of missing authentication. The local storage is cleared as well.
  • m

    melodic-ocean-83158

    08/24/2022, 7:12 PM
    In this way I don't see a problem. The problem was with that implementation you had used: "Cypress.env('userProd').username". it doesn't work.
  • m

    melodic-ocean-83158

    08/24/2022, 7:17 PM
    Sorry, but I didn't understand the question.
  • h

    hallowed-lighter-4305

    08/24/2022, 8:04 PM
    @melodic-ocean-83158 OK, calm down! the question is if using this implementation in the cypress.env.json file { "user": {}, "environment": "prod", "userProd" : { "username": "username", "password": "XXXXXXX" }, "userDev": { "username": "username", "password": "DEVpass" }, "userQA": { "username": "username", "password": "QApass$" } } then in the spec file where I have the conditions I'm just asking for the environment === "Prod". Then what would happen to the other environments? if (Cypress.env('enviroment') === "prod") { Cypress.env('user', Cypress.env('userProd')) } else { Cypress.env('user', Cypress.env('userDev')) }
  • p

    purple-shampoo-89307

    08/24/2022, 11:54 PM
    Hi! Is there an example documentation of integrating cypress in a gitlab pipeline when the cypress project is in a different repository than the web project?
  • i

    important-fireman-17295

    08/25/2022, 1:33 AM
    Does anyone know why this error is displaying? I automated logging into account.google.com, and it displayed this error after clicking the Next button. The code:
    Copy code
    cy.visit('accounts.google.com')
    cy.get('input[id="identifierId"]').type('my_email@gmail.com')
    cy.get('div[id="identifierNext"]').click()
    The error:
  • c

    cold-van-45410

    08/25/2022, 2:09 AM
    How to compare logo of website in cypress ? Basically I want to compare website logo expected with actual logo without comparing url of logo How can we do it in Cypress?
  • g

    gray-kilobyte-89541

    08/25/2022, 2:54 AM
    https://on.cypress.io/visual-testing ?
  • c

    cold-van-45410

    08/25/2022, 4:01 AM
    here is no solutions for logo comparison
  • s

    stale-optician-85950

    08/25/2022, 7:36 AM
    You've been told in multiple threads that what you are asking for is visual testing. Your logo is an image type (most likely), that is why you have been given the documentation link to visual testing.
  • w

    wonderful-wire-43244

    08/25/2022, 8:52 AM
    Hi, I have a list view with a slide-out area for filters. I'm trying to write a new command which can set these filters for me and before I can set them, I would need to check if the slide-out has ... slided out. I'm more a PHP guy and thus have difficulties wrapping my head around this. In PHP I would write something like if (!$elem->hasClass('visible')) {clickOnSlideOutButton()} ...do the actual setting of the filters As far as I understand it, this wouldn't be the way to go in cypress. The documentation I found so far is not clear to me either. Would anybody have an example how this would work out?
  • w

    wonderful-wire-43244

    08/25/2022, 8:53 AM
    And we are using cypress in our CI system and it starts a new browser for each test. Would there be a way to improve performance here somehow? Like reusing an existing browser instance or something like that?
  • a

    acceptable-hamburger-48790

    08/25/2022, 9:28 AM
    Give this a read https://docs.cypress.io/guides/core-concepts/conditional-testing
1...888990...192Latest