https://cypress.io logo
Join DiscordCommunities
Powered by
# e2e-testing
  • b

    big-judge-93427

    10/13/2022, 7:06 PM
    I want more than logging unfortunately. I'm trying to build out what the given/when/then statements would be and I was hoping to chain them up in a way that i could do something like this `cy.given('Some scenario') .someCommand() .anotherCommand() .when('This thing happens') .someCommand()
  • b

    big-judge-93427

    10/13/2022, 7:06 PM
    And then have it build out what normallly comes from the
    it
    description using the given/when/then methods in my example
  • b

    big-judge-93427

    10/13/2022, 7:07 PM
    i can do it with multiple it statements but that causes performance issues and is regarded as not a best practice
  • s

    stale-optician-85950

    10/13/2022, 7:09 PM
    Sure I get you. I'm not using Cucumber so I'm out of ideas for you. Good luck with it.
  • b

    big-judge-93427

    10/13/2022, 7:10 PM
    i'm not using it either. i was hoping to accomplish something similar with just vanilla Cypress. Thanks for responding πŸ™‚
  • b

    big-judge-93427

    10/13/2022, 7:10 PM
    i'm beginning to think it's just not possible
  • m

    millions-electrician-95804

    10/13/2022, 8:05 PM
    Hello ,I am facing this issue - after upgrade v10.10.0 , all 2nd tests will get page clear and reset to blank page . I reverted back to v10.9.0 and encounter the same .. earlier with 10.9.0 it was a smooth test run between it blocks . can anyone help to see how to retain the webpage application without clear / blank page - I am using - "Cypress.Cookies.preserveOnce() and Cypress.Cookies.defaults()" for saving cookies ..I did npx cypress prune... after upgrading to v 10.10.0.. and this issue is observed on all lesser versions now. How to retore - All active session data (cookies, localStorage and sessionStorage) - without cy.session & cy.origin . { experimentalSessionAndOrigin: false, testIsolation: 'legacy', } is not working
  • l

    limited-barista-33480

    10/13/2022, 10:05 PM
    Hey guys, can someone help me, how can I configure the profiles in cypress for the chrome browser and that it does not run in incognito mode
  • a

    adamant-mouse-7124

    10/14/2022, 8:32 AM
    Hello guys, can someone help me to find some good use case tests that includes canvas and how to make a signature? thank you in advance
  • s

    stale-optician-85950

    10/14/2022, 12:09 PM
    You can modify Chrome arguments as documented here https://docs.cypress.io/api/plugins/browser-launch-api but there is no 'does not run in incognito mode' flag. So find out what Chromium Command Line Switches you need enabled / disabled from (example) here https://peter.sh/experiments/chromium-command-line-switches/ and handle it with that first Cypress docs link.
    Copy code
    setupNodeEvents(on, config) {
          on('before:browser:launch', (browser = {}, launchOptions) => {
    // your code
  • c

    chilly-mechanic-84880

    10/14/2022, 12:51 PM
    I am setting up E2E test for my app which uses oAuth for authentication. cy.visit('app.domain.com). cy.origin("auth.domain.com",()=>{ cy.get('user').type('user'); cy.get('pass').type('pass'); cy.get('login).click() }) after clicking on login, it doesn't go back to app as authentication fails because of missing cookie. I am using cypress version 10.10.0.
  • c

    chilly-mechanic-84880

    10/14/2022, 12:51 PM
    any help is appreciated! Thanks in advance
  • s

    strong-application-30670

    10/14/2022, 1:37 PM
    Copy code
    js
    // perhaps look into default cookies
    Cypress.Cookies.default({
      foo: 'bar'
    })
    // or you can add cookies yourself
    cy.setCookie('foo', 'bar')
    // and remove afterwards
    cy.clearCookie('foo')
  • l

    limited-barista-33480

    10/14/2022, 1:55 PM
    @stale-optician-85950 Thank you very much for the information you share with me, but I don't quite understand what you have to do to configure the browser to run in normal mode. I was looking in the cypress documentation, and found this note: Cypress Profile, Cypress generates its own isolated profile apart from your normal browser profile. This means things like history entries, cookies, and 3rd party extensions from your regular browsing session will not affect your tests in Cypress. so I think that some configuration must be done to be able to execute in mode normal browser profile.
  • s

    stale-optician-85950

    10/14/2022, 2:04 PM
    I'm 99% sure what you are asking for is not possible. The docs you refer to are here https://docs.cypress.io/guides/guides/launching-browsers#Cypress-Profile and there is no mention of using your local Chrome state. That's why I linked you to the arguments approach so that you can configure the browser behaviour. What are you missing from your local Chrome that you want in Cypress Chrome?
  • l

    limited-barista-33480

    10/14/2022, 2:14 PM
    @stale-optician-85950 yes, what really fails is that when I run the test in cypress in the chrome browser mode that cypress uses it does not do it well, so that test to work must be run in the normal chrome mode since I did some manual tests and in that way if you do it right. I think it may be something you say on the subject of arguments so you can configure the behavior of the browser.
  • s

    stale-optician-85950

    10/14/2022, 2:17 PM
    Yes definitely explore the route of passing Chrome arguments. Otherwise, you'd never be able to run your tests in CI or on a colleague’s machine or anywhere only your only machine!
  • l

    limited-barista-33480

    10/14/2022, 2:32 PM
    @stale-optician-85950 yes, then for the argument theme for chrome you should look at this link that you send me https://peter.sh/experiments/chromium-command-line-switches/ and check what argument should I pass in the launchOptions configuration?
  • s

    stale-optician-85950

    10/14/2022, 2:38 PM
    I linked you that as an example of all the possible Chrome arguments. You never specified what exactly you need to configure Chrome to do, so I'm just giving general information. For example, If you need to keep cookies then you need to handle that differently. You're not giving me a lot of information to work with πŸ˜†
  • k

    kind-artist-92362

    10/14/2022, 5:00 PM
    how can i type smt that follow these rules string with pattern [0-9a-zA-Z_]{5, 10} was not registered before . What commands or constants should i use to implement this .
  • k

    kind-artist-92362

    10/14/2022, 5:08 PM
    maybe i should create a function ad pass in it all arguments
  • k

    kind-artist-92362

    10/14/2022, 5:24 PM
    function randomNumber(min, max) { return Math.random() * (max - min) + min; } let a = randomNumber(0,9) console.log(a)
  • k

    kind-artist-92362

    10/14/2022, 5:24 PM
    smt like this
  • k

    kind-artist-92362

    10/14/2022, 5:25 PM
    but how can i test it inside cypress and where all it should be saved
  • l

    limited-barista-33480

    10/14/2022, 5:49 PM
    @stale-optician-85950 πŸ˜† what I really need are the arguments to enable chrome notifications since when running the test with cypress it runs under the cypress automatic browser and this has several features disabled. I found something that I think can be useful, in the documentation they say the following: if we go to the link at the end of the text it does not lead to a page where it contains several arguments for chrome I don't know if it can help me to make configurations in cypress. https://github.com/cypress-io/cypress/blob/develop/packages/server/lib/browsers/chrome.ts#L36
  • s

    stale-optician-85950

    10/14/2022, 7:43 PM
    Yes exactly now you're getting it. You can override these default arguments already set in Cypress Chrome browser and you can also add your own. Add this code to your
    cypress.config.ts
    or
    .js
    (whichever your use), similar to the docs https://docs.cypress.io/api/plugins/browser-launch-api and launch
    Cypress open
    :
    Copy code
    setupNodeEvents: async (on, config) => {
          on(
            'before:browser:launch',
            (
              browser,
              launchOptions
            ) => {
              // `args` is an array of all the arguments that will be passed to browsers when it launches
              if (browser.family === 'chromium' && browser.name !== 'electron') {
                launchOptions.args.push('--auto-open-devtools-for-tabs', '--disable-application-cache');
                consola.info('Chromium flags set count:', launchOptions.args.length);
                consola.info('Chromium flags set list:', launchOptions.args);
              }
              return launchOptions;
            }
          );
    See that I'm logging (in my terminal) the number of arguments with
    .length
    and then all the arguments set list. There are 50 in total, 48 were by default and I added 2 more (so the Cypress team set 48 arguments to configure it how they want it by default, you can undo this). Also, you can do this trick https://docs.cypress.io/api/plugins/browser-launch-api#See-all-Chrome-browser-switches to see the list within the Chrome browser itself. Also, you'll see that Dev Tools is now open by default (as I like it)! Now once you see the list, you can think about which arguments relate to what you need enabled / disabled, you obviously need to Google around on this part. Play around with it until you get Cypress Chrome browser exactly as you need it. Then happy days πŸ‘
  • l

    limited-barista-33480

    10/14/2022, 8:25 PM
    @stale-optician-85950 Excellent, I thought I was on the right track, and now I'm done. It would just be to play with these configurations and see the behavior at the time of execution and the navigability with chorme. Thank you for your help and I'm glad that some of this also helps you for your tests. happy days πŸ‘
  • r

    refined-raincoat-56329

    10/14/2022, 9:53 PM
    hi guys can someone tell how to slide a carousel such as this
  • r

    refined-raincoat-56329

    10/14/2022, 9:54 PM
    I have been trying to use scroll on this but that does not work
  • r

    refined-raincoat-56329

    10/14/2022, 9:55 PM
    It's a mobile application
1...121122123...192Latest