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

    straight-rose-89671

    12/14/2022, 10:07 AM
    hello
  • c

    crooked-dress-73751

    12/14/2022, 10:30 AM
    is anyone using synpress
  • g

    gray-kilobyte-89541

    12/14/2022, 11:33 AM
    what is synpress
  • s

    straight-rose-89671

    12/14/2022, 1:40 PM
    When clicking on a certain link and not knowing what page that will be shown, is it okay to use the package waitIfHappens ? Or are there better ways Current setup:
    Copy code
    it('Clicking on a button - Load either page one step or page two', () => {
                cy.intercept('/page/*/packages').as('getPage')
                cy.intercept('/page/*/package').as('getPageTwo')
    
                cy.getBySel('button-page')
                    .find('a')
                    .first()
                    .click()
        
                cy.waitIfHappens({
                    alias: '@getPage',
                    timeout: 300,
                    yieldResponseBody: true,
                }).then((body) => {
                    if (typeof body !== 'undefined' && body.data) {
                        cy.wrap(body.data.pagedata)
                            .its('length')
                            .should('be.gte', 1)
                    }
                })
    
                cy.waitIfHappens({
                    alias: '@getPageTwo',
                    timeout: 300,
                    yieldResponseBody: true,
                }).then((body) => {
                    if (typeof body !== 'undefined' && body.data) {
                        cy.wrap(body.data.configurationData)
                            .its('length')
                            .should('be.gte', 1)
                    }
                })
            })
  • g

    gray-kilobyte-89541

    12/14/2022, 2:00 PM
    a better way would be to know exactly what to expect...
  • m

    mysterious-psychiatrist-29678

    12/14/2022, 2:01 PM
    Is Email Address label have the attr for
  • s

    straight-rose-89671

    12/14/2022, 2:09 PM
    Hahh, that is true but working dynamic data there is no way to tell if clicking the button has data for something. When not then you go directly to another page. Of course i'm testing each of those pages separately
  • t

    thousands-house-85089

    12/14/2022, 2:17 PM
    As a tester do you not need control over your data? This is quite a key concept. You should have either a way of seeding data which you can use to set up each test, or a specific set of data in a known state so you can test against it.
  • h

    helpful-dentist-23568

    12/14/2022, 2:25 PM
    Hi, is there is a way to clean the cache of a browser before test execution?
  • s

    straight-rose-89671

    12/14/2022, 2:27 PM
    Isn't the use of session taking part of that?
  • f

    fresh-doctor-14925

    12/14/2022, 2:33 PM
    Test isolation should take care of that automatically
  • m

    magnificent-cat-57082

    12/14/2022, 3:37 PM
    https://docs.cypress.io/api/commands/clearlocalstorage
  • m

    magnificent-cat-57082

    12/14/2022, 3:37 PM
    and plenty of other ones around there
    clearAllSessionStorage
    etc.
  • h

    handsome-army-58690

    12/14/2022, 3:45 PM
    Hi Guys, While writing a test case, I stuck with one scenario, we have a link in the table, and when I click that, it will open another application in a new window, but both are same domain. The problem is, we are passing some query parameters to bypass the sign-in if I go through the above steps. But when I click that cypress link, I can't see the query parameter in the URL, so applications keep navigating to the sign-in page. I don't understand what I'm doing wrong here. please anyone suggest the right approach to solve this issue. Thanks. I tested by hardcoding the below URL in the visit function, but still no luck. No query parameters are passed by cypress. cy.visit('https://domain.name.com/#/', { qs: { 'x-managed-user': 'Carrier-7c6e6496-ac6c-4787-80cc-d57fdfad2291' } }) On click URL: https://domain.name.com/#/?x-managed-user=Carrier-7c6e6496-ac6c-4787-80cc-d57fdfad2291; Navigating to the sign-in URL always: https://domain.name.com/#/signin Code : cy.window().then((win) => { cy.stub(win, 'open').as('windowOpen').callsFake(url => { cy.visit(url); }) }) cy.contains(id's', 'Create A Company Cy').click() cy.get('@windowOpen').should('have.been.calledOnce')
  • p

    powerful-king-41699

    12/14/2022, 6:24 PM
    Hello Everyone, We run our E2E tests against Chrome 70 on windows machine in headed mode using command npm install && cypress run --browser chrome --headed "--config" "baseUrl=http:serveraddress:8080" "--env" "Host=serveraddress". The tests connect to a server url hosted on a Linux machine (hosted on our network). We recently upgraded our cypress version from 7.7.0 to 11.2.0 and the tests started failing where the tests fail at visit step with Failed to construct 'URL': Invalid URL as shown in the img uploaded.
  • p

    powerful-king-41699

    12/14/2022, 6:25 PM
    Here is our jenkins script below:
    Copy code
    env.cypressFFBaseUrl=cypressFFBaseUrl.trim()
         env.FFHost=FFHost.trim()
         bat  script: """
                                     setlocal
                                     set ERRORLEVEL=0
                                     set PATH=C:\\Program Files (x86)\\OpenJDK\\jdk-8.0.262.10-hotspot\\bin;$PATH
                                     set CYPRESS_BASE_URL=${cypressFFBaseUrl};
                                     set Host=${FFHost};
                                     set CYPRESS_RUN_BINARY=C:\\Users\\Admin\\AppData\\Local\\Cypress\\Cache\\11.2.0\\Cypress\\Cypress.exe
                                     cd $WORKSPACE/ui/e2e
                                     npm run cy:run-firefox-headed -- --config baseUrl=${cypressFFBaseUrl} --env Host=${FFHost}  >> e2e_err.log
         """
  • p

    powerful-king-41699

    12/14/2022, 6:25 PM
    cypress.conf.ts:
    Copy code
    import {defineConfig} from "cypress";
    
    export default defineConfig({
      video: true,
      videoCompression: 20,
      viewportWidth: 1680,
      viewportHeight: 1050,
      MOZ_FORCE_DISABLE_E10S: 1,
      numTestsKeptInMemory: 1,
      defaultCommandTimeout: 12000,
      reporter: "junit",
      animationDistanceThreshold: 0,
      reporterOptions: {
        mochaFile: "results/cypress-report[hash].xml",
        toConsole: true,
      },
      retries: {
        runMode: 1,
        openMode: 0,
      },
      env: {
        mlHost: "localhost",
        FAIL_FAST_STRATEGY: "spec",
      },
      e2e: {
        // We've imported your old cypress plugins here.
        // You may want to clean this up later by importing these.
        setupNodeEvents(on, config) {
          return require("./cypress/plugins/index.js")(on, config);
        },
        baseUrl: "http://localhost:8080",
        experimentalRunAllSpecs: true,
        specPattern: ["cypress/e2e/*/*/*.cy.{js,jsx,ts,tsx}", "cypress/e2e/*/*.cy.{js,jsx,ts,tsx}"],
        excludeSpecPattern: [],
      },
    });
    spec:
    Copy code
    describe("Add step ", () => {
      before(() => {
        cy.visit("/");
        cy.contains(Application.title);
        cy.loginAsDeveloper().withRequest();
        LoginPage.postLogin();
        //Saving Local Storage to preserve session
        cy.saveLocalStorage();
      });
    it("Navigating to Customer Match tab", () => {
        toolbar.getToolbarIcon().should("be.visible").click();
      });
    });
    Have been stuck with this for a long time. Please Help!
  • f

    fresh-doctor-14925

    12/15/2022, 9:06 AM
    !duplicate
  • n

    nutritious-analyst-96582

    12/15/2022, 9:06 AM
    Uh oh, It looks like you have posted the same question in multiple channels. Help us prevent spam by removing any duplicates of your questions, Thanks! 😀
  • a

    adorable-stone-42197

    12/15/2022, 12:36 PM
    Has anyone tried starting the site, entering their email, and clicking the next button, which then redirects to OKTA? Have example someone of login command?
  • r

    rough-agent-43374

    12/15/2022, 1:18 PM
    Hey guys, maybe someone can help me with my problem. Im basically trying to .get() a button which triggers a href with a _blank. But for some reason my element cant be find with .get(), although this works sometimes but most of the times not. I even integrated an intercept() and wait() before, so that the requests are finished before processing the button (Just in case cypress is faster then my requests) but even this does not seem to help. Hope someone can help me, thanks 🙂
  • r

    rough-agent-43374

    12/15/2022, 1:24 PM
    Btw this is the app code for the element
  • t

    thankful-wire-37848

    12/15/2022, 1:38 PM
    Can you try
    expect($a).to.have.attr('href', '...')
    instead? (btw it is a button, not an anchor so better to name the variable "$button" instead)
  • r

    rough-agent-43374

    12/15/2022, 1:59 PM
    Sadly it does not fix the problem, but i think the bug starts a little earlier with .get(). The assertion says it fails with expect "undefined" ... probably because get does not what it should so the url is undefined
  • t

    thankful-wire-37848

    12/15/2022, 2:08 PM
    I think I see it now. There is no "href" attribute on the button. You seem to be wanting to select the form and assert for the action attribute:
    cy.get('{the form selector}').should('have.attr', 'action', '{the expected action URL}')
    . Same for the target attribute.
  • r

    rough-agent-43374

    12/15/2022, 2:27 PM
    Oh damn thank you really much, i overlooked that 😂 Works now
  • m

    mysterious-psychiatrist-29678

    12/15/2022, 4:55 PM
    I have another question this time about cy.session(). I want to log in once so that scenarios don't need to do. therefore implemented login in a session as a custom command then invoke in beforeEach hook. but seems beforeEach log in but at the start of the 1st scenario just gives a blank page and obviously fail. why does Cypress says that it clears the page and the end of the hook?
    Copy code
    Cypress.Commands.add('loginOnUI',  (username, password, visitingUrl) => {
    
      cy.session([username, password], () => {
        cy.visit(visitingUrl)
    
        cy.origin('login.microsoftonline.com', () => {
          cy.get("input[type='email']")
            .type(Cypress.env('username'))
          cy.contains('Next').click();
        })  
    
        cy.origin('login.live.com', () => {
          cy.get("input[type='password']")
            .type(Cypress.env('password'))
          cy.contains('Sign in').click()
          cy.contains('Yes').click()
        })
    
        cy.contains('Loading...', {timeout: 40000})
          .should('not.be.visible')
      })
    }
    Copy code
    beforeEach(() => { 
            cy.loginOnUI(Cypress.env('username'), Cypress.env('password'), visitingUrl)
        })
  • h

    happy-megabyte-98400

    12/15/2022, 7:28 PM
    Hello all, anyone noticing issues with grepFilterSpecs while using @billions-barista-30103/grep package?
  • h

    happy-megabyte-98400

    12/15/2022, 7:29 PM
    I set grepFilterSpecs & grepOmitFiltered as env variables and they're not being respected
  • t

    thankful-wire-37848

    12/15/2022, 7:57 PM
    Is this in Cypress v12? Then this is probably due to the new test isolation "feature" and this is the designed/desired behavior (that's why Cypress 12 is a major release because of this breaking change ao.). You can switch test isolation off btw, but I wouldn't recommend it. Better to fix the tests with an extra
    cy.visit(...)
    . More details here: https://docs.cypress.io/api/commands/session#When-the-page-and-session-data-are-cleared
1...169170171...192Latest