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

    gentle-accountant-4760

    06/28/2022, 12:18 PM
    Yupp either that or go back by clicking arrows in the webpage
  • f

    fresh-doctor-14925

    06/28/2022, 12:20 PM
    I tend not to structure tests like that. As much setup as possible via API, and then go directly to the page I wish to test.
  • f

    fresh-doctor-14925

    06/28/2022, 12:20 PM
    A lot of my approach comes from this presentation from the fellow that wrote cypress. Old but good

    https://www.youtube.com/watch?v=5XQOK0v_YRE▾

  • g

    gentle-accountant-4760

    06/28/2022, 12:21 PM
    yeah my problem is that if I use session then I cant use cy.visit on each test as some of my links are dynamic created
  • g

    gentle-accountant-4760

    06/28/2022, 12:21 PM
    so it lefts me with beforeEach
  • f

    fresh-doctor-14925

    06/28/2022, 12:23 PM
    I don't know what you mean? Session just gives you a way to store cookies But this sounds a lot like dependencies between scenarios. In that case, why not just have them in one scenario?
  • g

    gentle-accountant-4760

    06/28/2022, 12:24 PM
    Because I still want to keep my 'it' tests - if thsts what you mean?
  • f

    fresh-doctor-14925

    06/28/2022, 12:26 PM
    I don't know that I'm really following what exactly you're trying to do
  • g

    gentle-accountant-4760

    06/28/2022, 12:26 PM
    so it is something like:
    Copy code
    Suite
       Before
    
    Scneario
      it
      it
      it
      it
    Thats how I have it today
  • g

    gentle-accountant-4760

    06/28/2022, 12:26 PM
    Maybe that is incorrect way to do it?
  • f

    fresh-doctor-14925

    06/28/2022, 12:26 PM
    Why are you using a
    before
    and not
    beforeEach
  • g

    gentle-accountant-4760

    06/28/2022, 12:27 PM
    so my goal is that for each
    it
    tests, I want to keep the sessions for the whole rest of the test
  • g

    gentle-accountant-4760

    06/28/2022, 12:27 PM
    but I cannot use cy.visit on each test neither
  • f

    fresh-doctor-14925

    06/28/2022, 12:27 PM
    > but I cannot use cy.visit on each test neither But why?
  • g

    gentle-accountant-4760

    06/28/2022, 12:28 PM
    as I e.g. lets say first 'it' test, I click on a button that redirects me to a page. In that page I want to do stuff as check expect etc etc. Once that is done, then on my last it, I want to redirect back to the homepage
  • g

    gentle-accountant-4760

    06/28/2022, 12:28 PM
    which all the cookies stored
  • f

    fresh-doctor-14925

    06/28/2022, 12:29 PM
    The cookies are stored in the browser, not the homepage. And anyhow, things like context, cookies, are at risk of being cleared between
    it()
    blocks
  • g

    gentle-accountant-4760

    06/28/2022, 12:30 PM
    Right and that is whats happening as I can see. what I could do is perhaps just Preserve the cookie I actually need?
  • f

    fresh-doctor-14925

    06/28/2022, 12:31 PM
    cy.session()
    is designed for that very use case. I'd suggest either refactoring your tests to make use of it, or merge all of your
    it()
    blocks into one
  • g

    gentle-accountant-4760

    06/28/2022, 12:33 PM
    Alright! thanks alot 😁 I see the pattern I can actually do with your help
  • s

    salmon-river-93816

    06/28/2022, 12:36 PM
    I forgot I was using Cypress 10.2.0 and badball/cypress-cucumber-preprocessor 11.3.0.
  • s

    salmon-river-93816

    06/28/2022, 12:49 PM
    Here is a screenshot of the scenario:
  • s

    salmon-river-93816

    06/28/2022, 12:50 PM
    Here is a screenshot of the testing process:
  • s

    some-angle-80895

    06/28/2022, 1:03 PM
    Hello, i am a little stuck with something here.... i am trying to invoke "value" attr and store them into a constant to create an array, not sure if it is possible tho 🙂 source example (created it so i can post it on stackoverflow as well): this is the code that i am trying to run: cy.get('[data-tab-name-prefix="selectedFonds[0]"]') .scrollIntoView() .should('be.visible') .find('[name="selectedFonds[0][name]"]') .find('option') .invoke('attr', 'value').then($options => { cy.log($options) }) right now it is only logging the first value of the first option... but i need all of them
  • s

    some-angle-80895

    06/28/2022, 1:04 PM
    does someone have any idea how to get all values and create an array ? thanks!
  • w

    wooden-teacher-96595

    06/28/2022, 1:30 PM
    hey all, is there any way to test the response time of a call or how long a component takes to load?
  • s

    salmon-river-93816

    06/28/2022, 1:57 PM
    In fact, I discovered that the problem was related to the badeball/cypress-cucumber-preprocessor library and not to Cypress.
  • r

    rough-magazine-51515

    06/28/2022, 2:33 PM
    How to run Test with docker
  • r

    rough-magazine-51515

    06/28/2022, 2:33 PM
    Could not find a Cypress configuration file in this folder: /e2e
  • l

    late-planet-4481

    06/28/2022, 3:20 PM
    I think you want something like this. It can probably be written cleaner; apologies 🙂
    Copy code
    let myArray = []
    cy.get('option').each((x) => {
      cy.wrap(x).invoke('val').then((val) => myArray.push(val))
    })
1...979899...252Latest