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

    fancy-airplane-60156

    08/16/2021, 5:19 AM
    describe('login scenario using task', () => { before(() => { cy.task('getSession', {username:’xx.hhhh, password: ‘xxxxxxx’, url: Cypress.env("login_url")}) .then(session => { cy.restoreSession(session); }) }) Cypress.Commands.add('restoreSession', function ({cookies, lsd, ssd}) { const wList = []; cy.clearCookies(); cookies.forEach(cookie => { wList.push(cookie.name); cy.setCookie(cookie.name, cookie.value, { log: true, domain: cookie.domain, path: cookie.path, expiry: cookie.expires, httpOnly: cookie.httpOnly, secure: cookie.secure }); }); Cypress.Cookies.defaults({ preserve: wList }); cy.window().then(window => { Object.keys(ssd).forEach(key => window.sessionStorage.setItem(key, ssd[key])); Object.keys(lsd).forEach(key => window.localStorage.setItem(key, lsd[key])); }); });
  • l

    late-sundown-90898

    08/16/2021, 3:34 PM
    We're running into issues with
    visit()
    with our Vue app. Locally, or against a dev install works fine, but when testing against the app when deployed on S3, we'll get a page not found. I'm assuming this has something to do with the routing when hosted on S3. Would anyone have any links to point me to for workarounds to this? For the moment, I'm just replacing them by clicking through the app.
  • p

    plain-lifeguard-91120

    08/16/2021, 4:34 PM
    how would you guys recommend catching a bad request that is only printing to the console and not being caught by cypress?
  • b

    boundless-jackal-97384

    08/16/2021, 6:29 PM
    guys, do you know if the cypress can record the puppeteer process, calling in a test of cypress?
  • p

    plain-lifeguard-91120

    08/16/2021, 8:22 PM
    is anyone getting issues with chromeWebSecurity again? I set it to false and it stopped working again
  • p

    plain-lifeguard-91120

    08/16/2021, 8:23 PM
    yeah if I understand correctly if you want to record your test theres some documentation on it here https://docs.cypress.io/guides/dashboard/runs#Run-details
  • p

    plain-lifeguard-91120

    08/16/2021, 8:24 PM
    if you wanted to record like a separate puppeteer part im not too sure
  • b

    boundless-jackal-97384

    08/16/2021, 8:25 PM
    for me that's ok
  • p

    plain-lifeguard-91120

    08/16/2021, 8:30 PM
    yeah it works in the electron browser but not chrome
  • p

    plain-lifeguard-91120

    08/16/2021, 8:30 PM
    idk why
  • b

    boundless-jackal-97384

    08/16/2021, 8:30 PM
    what is your version on your cypress?
  • b

    boundless-jackal-97384

    08/16/2021, 8:31 PM
    and for this, let me explain my situation.. on a test, i want to do a scenario, where the user received the invite to login the first time in a system, but i need to take a generic password that he received on email. for this part, i use the puppeteer, to take the password, and at the final, i pass to cypress, and finalize with the login. But sometimes when i run on the pipeline, this part to take the password is failing, and i need to see the error, so i want to record. so my doubt is, can cypress record this task that puppeteer is already making?
  • p

    plain-lifeguard-91120

    08/16/2021, 8:36 PM
    I'm certainly no professional with cypress, but have you tried using "npx cypress open" instead of run so you can see the GUI ? I believe you should be able to see the entire process with the GUI
  • b

    boundless-jackal-97384

    08/16/2021, 8:47 PM
    yeah, if i run locally i can see the log, but the error is giving only when i run on pipeline
  • b

    boundless-jackal-97384

    08/16/2021, 8:49 PM
    so, i need to record this error, but probably the cypress could not do this
  • c

    cuddly-helicopter-33279

    08/17/2021, 12:18 AM
    That's what the Dashboard is all about
  • c

    cuddly-helicopter-33279

    08/17/2021, 3:26 AM
    Just updated this in 8.3
  • f

    fancy-airplane-60156

    08/17/2021, 5:58 AM
    Hi All, please can you help me resolve the issue i reported earlier. It seems setting cookie and local storage isn;t a good idea in case of scenarios involving SAML / Oauth
  • p

    plain-lifeguard-91120

    08/17/2021, 2:18 PM
    it seems like its broken in 8.3
  • c

    cuddly-helicopter-33279

    08/17/2021, 2:30 PM
    New since 8.2, Have you looked in using cy.session? https://docs.cypress.io/api/commands/session
  • p

    plain-lifeguard-91120

    08/17/2021, 7:14 PM
    I'm using cy.clearCookies(); and cy.clearLocalStorage(); but sessions are still not being fully cleared on external URLs
  • b

    boundless-activity-75504

    08/17/2021, 7:31 PM
    hi guys. does anyone knows if i can use cy.session in git lab ci process ??? im getting a error hen i try to login using cy.session >>>
    cy.wait()
    timed out waiting
    30000ms
    for the 1st request to the route:
    login
    . No request ever occurred.
  • f

    fancy-airplane-60156

    08/18/2021, 2:23 AM
    Thanks for this @User I'll have a read of this straight away.
  • f

    fancy-airplane-60156

    08/18/2021, 9:01 AM
    Hi @User I did solve my issue. I did not end up using this feature. But it's great feature to be aware of. Thanks very much for your response.
  • d

    dazzling-pillow-26039

    08/19/2021, 4:18 PM
    Have you cleared session storage too?
  • d

    dazzling-pillow-26039

    08/19/2021, 4:20 PM
    The snippet you using is developed by me. I am preserving the cookies as defaults. So, the cookies never get deleted actually. Use preserve once instead
  • d

    dazzling-pillow-26039

    08/19/2021, 4:23 PM
    Is this is the repo you used ? https://github.com/vrknetha/cypress-thirdparty-login
  • f

    future-gold-77198

    08/19/2021, 7:03 PM
    After reading the new session API docs, I want to try it. But I wanted to check if anything obvious might not work with our pretty non-standard login flow. We use Playwright to login much like this https://github.com/estruyf/cypress-msteams-sample This is the code I adapted for our use, since MS Active Directory is the auth service behind the app. So through a task, Cypress initiates Playwright, which logins, saves the cookies and local storage, then passes it back to cypress. Then the cookies/items are set in the Cypress spawned browser in the login command. The only difference I can really think of is that I believe I need to do cy.visit() after setting the cookies/items to truly finalize the login (make sure it is valid with the server and all is hunky dory). So I guess I would do cy.visit at the end of the 'setup' within cy.session, instead of at the beginning. None of this raises any immediate red flags for cy.session usage for anyone, does it?
  • f

    fancy-airplane-60156

    08/19/2021, 10:48 PM
    Hi @User Yes this is the one. It's working now. I had to reorder few things in my test. Thanks for this. It's very helpful. I was looking at how I can extend this to a few tests that are in a single Js file .
  • f

    future-gold-77198

    08/20/2021, 3:28 AM
    Session API issues
1...202122...192Latest