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

    rough-night-37887

    10/12/2022, 8:02 AM
    I created a Issue that explains it better here https://github.com/badeball/cypress-cucumber-preprocessor/issues/858
  • m

    mysterious-belgium-25713

    10/12/2022, 8:12 AM
    You are using classes but i don't see you initialize the class. Maybe that's why I cannot find the searchGuestpage
  • r

    rough-night-37887

    10/12/2022, 8:13 AM
    well its Static and it works if I call it directly
  • r

    rough-night-37887

    10/12/2022, 8:14 AM
    like this it works searchGuestPage.getMyLocator().type(value);
  • f

    freezing-piano-2792

    10/12/2022, 8:23 AM
    You’re using eval for something that could otherwise be solved using eg a switch statement to obtain the correct page object reference, just drop the approach altogether
  • r

    rough-night-37887

    10/12/2022, 8:31 AM
    No if its a lot of different pages and different locators, it would be super big
  • r

    rough-night-37887

    10/12/2022, 8:31 AM
    but I guess its not possible to use it like that,
  • f

    freezing-piano-2792

    10/12/2022, 8:34 AM
    It probably is possible , but any issues you might encounter doesn’t warrant posting a ticket in the above-mentioned tracker, this is just JS
  • m

    mysterious-belgium-25713

    10/12/2022, 8:38 AM
    Maybe try it out in a js repl instance. But i dont know if the eval function works with static members
  • r

    rough-night-37887

    10/12/2022, 8:40 AM
    Do you have a good way to do something like this? instead of creating steps for each different locator?
  • f

    freezing-piano-2792

    10/12/2022, 8:53 AM
    Interacting with form elements isn’t or shouldn’t be unique for each screen and thus needn’t be hidden in each page object
  • f

    freezing-piano-2792

    10/12/2022, 8:53 AM
    Anything that is unique does warrant its own step definition
  • m

    mysterious-belgium-25713

    10/12/2022, 9:03 AM
    The goal of BDD is not to have one function that does everything. The goal of BDD is to have a human readable behavior of your end user.
  • m

    mysterious-belgium-25713

    10/12/2022, 9:05 AM
    An end user would never say i would set field to value. An user would say more in the line of Then i will fill in the form or specific field.
  • c

    cold-van-45410

    10/12/2022, 12:03 PM
    After executing 7 it block session closed message is shown . How can i resolve it??
  • m

    magnificent-finland-58048

    10/12/2022, 12:37 PM
    do you mean serve the app on localhost:3000 and run the tests against it? here are 3 examples tour-of-heroes-react-cypress-ts - the final app from my gitbook https://app.gitbook.com/s/jK1ARkRsP5OQ6ygMk6el/ https://github.com/muratkeremozcan/tour-of-heroes-react-cypress-ts react-hooks-in-action-with-cypress - the final app built in React Hooks in Action book https://github.com/muratkeremozcan/react-hooks-in-action-with-cypress bookshelf - the final app from Epic React https://github.com/muratkeremozcan/bookshelf
  • m

    magnificent-finland-58048

    10/12/2022, 12:38 PM
    here's an Angular example https://github.com/muratkeremozcan/angular-playground
  • i

    important-fish-21193

    10/12/2022, 1:05 PM
    I am currently experimenting with cy.session with cacheAcrossSpecs option. However cypress throws below error, not sure where am I going wrong. "cy.session()` was passed an invalid option: cacheAcrossSpecs Available options are:
    validate
    "
  • i

    important-fish-21193

    10/12/2022, 1:07 PM
    cy.session(user,()=>{}, {validate(){some validations},cacheAcrossSpec:true})
  • i

    important-fish-21193

    10/12/2022, 1:07 PM
    this is how my session command looks like
  • i

    important-fish-21193

    10/12/2022, 1:08 PM
    any help would be much appreciated. Thanks.
  • s

    stale-optician-85950

    10/12/2022, 1:14 PM
    Specs is plural, so its:
    cacheAcrossSpecs: true,
    not
    cacheAcrossSpec:true
    https://docs.cypress.io/api/commands/session#Caching-session-data-across-specs
  • i

    important-fish-21193

    10/12/2022, 1:16 PM
    sorry for typo in my chat message but I do have it correctly typed in my code.
  • s

    stale-optician-85950

    10/12/2022, 1:21 PM
    Copy code
    cy.session(name, () => {
            cy.request({
              method: 'POST',
              url: '/login',
              body: { name, password: 's3cr3t' },
            }).then(({ body }) => {
              window.localStorage.setItem('authToken', body.token)
            })
          }, {
            validate() {
                cy.visit('/user_profile')
                cy.contains(`Hello ${name}`)
              },
              cacheAcrossSpecs: true,
            }
    When I hover over
    cacheAcrossSpecs
    in that documentation code locally I get a correct reference. Do you?
  • s

    stale-optician-85950

    10/12/2022, 1:23 PM
    You might need to double and triple-check your syntax and positioning of that property.
  • s

    stale-optician-85950

    10/12/2022, 1:46 PM
    @important-fish-21193
    cacheAcrossSpecs
    was added in Cypress version 10.9.0 https://docs.cypress.io/guides/references/changelog#10-9-0 make sure you are using at least this version.
  • i

    important-fish-21193

    10/12/2022, 2:07 PM
    Damn! I am on 10.6.0. will update it to latest version. Thank you for prompt response. will let you know how I get on.
  • i

    important-fish-21193

    10/12/2022, 2:21 PM
    updated to latest version and it just works fine. Thanks for your help much appreciated. 🙂
  • s

    stale-optician-85950

    10/12/2022, 2:22 PM
    You're welcome @important-fish-21193 I'm glad it's sorted.
  • l

    limited-barista-33480

    10/12/2022, 3:28 PM
    Hey guys, can someone help me with this, how can I run a test in cypress using chrome, but not start the browser in incognito mode since it blocks notifications, is there any configuration at the code level for this?
1...119120121...192Latest