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

    gray-kilobyte-89541

    10/26/2022, 10:32 AM
    The price will go up soon too, since I added so many more bonus lessons
  • q

    quaint-hospital-22081

    10/26/2022, 10:43 AM
    @gray-kilobyte-89541 please any advise?
  • s

    stale-optician-85950

    10/26/2022, 11:00 AM
    @quaint-hospital-22081 is your corporate proxy configuration correct when you view the settings in Cypress UI, like the docs here https://docs.cypress.io/guides/references/proxy-configuration#View-proxy-settings-in-Cypress ? Maybe your devOps team has changed the proxy, you should also double-check with them and show them the proxy details you set and see in Cypress UI for confirmation.
  • l

    limited-fish-66138

    10/26/2022, 1:21 PM
    Hello , we have E2E cypress repo and we use parallelisation with 3 tags running with mochawesome-merge, devops stores daily report in nexus and email sent has only nexus link. Is there any way to email only status (only test counts) as email, 1 email with all 3 tags test counts ?? Thanks
  • f

    fast-artist-45202

    10/26/2022, 2:12 PM
    Hi folks! I'm trying to get account information by using
    cy.request
    to hit an API endpoint that should return all the account info in the response. I need to create disposable accounts on the fly, then have Cypress get the account ID number so that we can use an e2e endpoint to make changes to the account to get it in the state it needs to be in for testing. I'm using this:
    Copy code
    cy.request({
            method: "GET",
            url: "https://my.api.url/customers/me",
            headers: {
              "Content-Type": "application/vnd.api+json",
            },
          }).then((response) => {
            cy.log(response.body);
          });
    I'm getting a 200 response in Cypress's ui, but I should be getting an array full of customer info, but instead I'm not seeing anything in the console or network tab, and the log only says
    {data: Object{3}}
    Can someone tell me what I'm doing wrong? Thanks much!
  • f

    fresh-doctor-14925

    10/26/2022, 2:13 PM
    If you're running locally, you will be able to look inside the object if you replace
    cy.log
    with
    console.log
    and have the developer tools open
  • f

    fast-artist-45202

    10/26/2022, 2:16 PM
    Thanks! will try that just to make sure I'm getting the right stuff. I actually need to do this in a CI pipeline eventually, so what I need is for Cypress to be able to receive that response, set the customer ID to a variable so that later it can change account info by
    cy.request
    to an e2e endpoint that uses that customer ID number. Is there a way to make that visible to cypress so I can use it in this way?
  • f

    fresh-doctor-14925

    10/26/2022, 2:19 PM
    That should be fairly straightforward. Just seems like you'd need to inspect the response and then alias it. Have you looked up the docs for aliasing? https://docs.cypress.io/api/commands/as
  • f

    fast-artist-45202

    10/26/2022, 2:19 PM
    Ooh, so wait, I see maybe since we are definitely getting
    {data: Object{3}}
    , it's already available to cypress even though I don't see it! So, since we're getting the data object, and if I console log it, I can figure out exactly how it's formatted and check for that value
  • f

    fast-artist-45202

    10/26/2022, 2:20 PM
    Okay, I'll review docs for aliasing, thanks much.
  • f

    fast-artist-45202

    10/26/2022, 2:53 PM
    If I can poke a little more, is there a tutorial or something that I can review to learn how to work with this info with Cypress? I'm seeing exactly what I'm looking for, but I'm not quite there
  • f

    fast-artist-45202

    10/26/2022, 2:55 PM
    I have the following:
    Copy code
    cy.intercept("GET", "*/customers/me").as("customerInfo");
          cy.request({
            method: "GET",
            url: "https://my.api.site/customers/me",
          }).then((response) => {
            console.log(response.body);
          });
          cy.get("@customerInfo")
            .its("response.body")
            .invoke("attr", "customerId")
            .then(($customerID) => {
              console.log($customerID);
            });
    And I'm definitely seeing the info I need, it's structured like this:
  • b

    brash-mechanic-5372

    10/26/2022, 3:08 PM
    How can I test emails and forms that are already on production environment but without getting the information delivered to the actual client inbox?
  • a

    acceptable-solstice-90676

    10/26/2022, 3:16 PM
    Hi everyone, I have the following in my
    e2e.js
    file (see file attached), that works pretty good for me, but I face a problem, if a test fails or for some reason is not finished, and the next one is going to run, Cypress is logging in with the account of the test that failed, even if I have one of these options set in before/beforeEach/after/afterEach: -
    cy.clearCookies
    -
    Copy code
    cy.clearCookie('sessionID')
    -
    Cypress.session.clearAllSavedSessions()` I logging as follow: Cypress.Commands.add('loginByAPI', (email, password='mypassword') => { cy.clearCookies('sessionID') //added this to try here cy.request({ method: 'POST', url: Cypress.env('accountAPIUrl') + '/security/login2', body: { "email": email, "password": password, } }).then((response) => { expect(response.status).to.eq(200) cy.log({ name: 'loginResponse', message: response.body.sessionID }) cy.log({ name: 'loginResponse', message: response.body.email }) cy.setCookie('sessionID', response.body.sessionID) cy.visit(
    /
    ); }) })
  • f

    fast-artist-45202

    10/26/2022, 3:30 PM
    I figured it out, thanks for those who helped me!
    Copy code
    cy.request({
            method: "GET",
            url: "https://my.api.site/customers/me",
          }).then((response) => {
            console.log(response.body.data.attributes.customerId);
          });
    It's printing the Id properly, so I can go from there and assign the value to a variable. Didn't realize I had to chain every layer of the response body, but now I do
  • e

    early-article-61542

    10/26/2022, 4:30 PM
    What is the best way to check that an element is present before clicking on it
    Copy code
    ts
    cy.get('.search-button').click() // sometimes fails
    // want to check if element is present before
    But if I use
    Copy code
    ts
    if(Cypress.$('.search-button').length) {
      // the block is never executed
    }
  • g

    gray-kilobyte-89541

    10/26/2022, 4:49 PM
    how does it fail?
  • e

    early-article-61542

    10/26/2022, 4:55 PM
    cannot click on an undefined element
  • a

    acoustic-lock-46014

    10/26/2022, 5:10 PM
    @early-article-61542 try this
    Copy code
    Cypress.Commands.add('yourCustomCommand', () => {
      cy.wait(4000)
      cy.get('body')
        .then($body => {
          if (${elementYouWantToClick/wait}.length) {
            return true;
          }
    
          return false;
        })
        .then(boolean => {
          if(boolean){
            cy.get(${elementYouWantToClick).click();
          } else {
            cy.wait(100)
          }
      });
    })
  • g

    gray-kilobyte-89541

    10/26/2022, 5:14 PM
    Is the element not there? https://on.cypress.io/click already has built-in element check. Is the element not present on the page?
  • t

    tall-forest-29063

    10/26/2022, 5:33 PM
    Hello! Just started learn Cypress E2E test automation on my demo app. Could someone please help me ?And facing the issue that Cypress can't load page content in Chrome browser (it shows just blamk page) At the same time Cypress perfectly loads data in Firefox (for the same app)
  • t

    tall-forest-29063

    10/26/2022, 5:35 PM
    here is config file const { defineConfig } = require("cypress"); module.exports = defineConfig({ chromeWebSecurity: false, e2e: { setupNodeEvents(on, config) { // implement node event listeners here }, "viewportWidth":1980, "viewportHeight":1020, "screenshotsFolder": "mochawesome-report/assets", "videosFolder": "mochawesome-report/assets", baseUrl: 'http://power-inspiration-1088-dev-ed.scratch.my.site.com/ebikes', }, });
  • t

    tall-forest-29063

    10/26/2022, 5:42 PM
    the test itself is simple open url describe('First Test', () => { it('Open', () => { cy.visit('/') }) })
  • t

    tall-forest-29063

    10/26/2022, 6:09 PM
    @gray-kilobyte-89541 Could you please take a look?
  • f

    fresh-doctor-14925

    10/26/2022, 6:50 PM
    Yeah, I am experiencing the same when attempting to visit https://power-inspiration-1088-dev-ed.scratch.my.site.com/ebikes/s/ Weird that it works fine on Firefox. It's pretty easy to replicate, so I suggest that you raise an issue on the Cypress github https://github.com/cypress-io/cypress/issues
  • f

    fresh-doctor-14925

    10/26/2022, 6:58 PM
    Yesss! Well done! Now, if you really want to deep dive into network responses and playing around with them, it would be worth investing in Gleb's course https://cypress.tips/courses/network-testing (not affiliated with this paid course in any way. It just helped me a lot)
  • t

    tall-forest-29063

    10/26/2022, 9:15 PM
    Thanks, @fresh-doctor-14925 will post an issue
  • s

    stale-optician-85950

    10/26/2022, 9:25 PM
    This is an interesting issue, so I just fired up your application too and I see the same: You'll notice that in any of the Chromium-based browsers no POST requests are generated, only a few GET requests. You can see this in both the Cypress UI runner (left side) logs and in Dev Tools > Network, versus manually doing this in normal Chrome. So I wonder if one of the default Chrome arguments passed with Cypress Chrome is blocking your application from making these POST requests! See the docs here https://docs.cypress.io/api/plugins/browser-launch-api#See-all-Chrome-browser-switches, there are at least 50 arguments / switches set in default Cypress. It's not easy to go through all those arguments 1 by 1 and disable / enable. So I agree with @fresh-doctor-14925 that this deserves a Cypress github issue. And I'm interested to know the outcome of this one too 🤔
  • b

    billowy-librarian-83114

    10/26/2022, 10:01 PM
    I can't figure out why my text input goes away when the {enter} key is hit. it doesn't happen when I use the website manually. i tried adding a wait before finding the element to make sure the page loaded, but it seems to be some kind of timing issue with entering the input field, typing, and hitting enter.
    Copy code
    cy.get('@item')
                                .click()
                                .find('input')
                                .should('be.visible')
                                .type(`${rowData['Value']['value']}{enter}`, { delay: 190 })
                                cy.get('@item').should('have.text', rowData['Value']['value'])
  • b

    billowy-librarian-83114

    10/26/2022, 10:16 PM
    okay, so this works. is there a way to accomplish this without adding in static waits?
    Copy code
    cy.get('@item')
                                .click()
                                .find('input')
                                .should('be.visible')
                                .type(rowData['Value']['value'])
                                cy.wait(1000)
                                cy.get('@item')
                                .find('input')
                                .type(`{enter}`)
                                cy.wait(1000)
                                cy.get('@item').should('have.text', rowData['Value']['value'])
1...130131132...192Latest