https://cypress.io logo
Join Discord
Powered by
# i-need-help
  • Cypress-Base64
    a

    abundant-alarm-34669

    02/15/2023, 12:30 PM
    Hello guys, I'm new to Cypress API testing, I have a Base64data string (it has over 150000 characters) which I need to encode... I'm trying to copy it from SoapUI... Any idea how can I make this as a file and then do cy.readFile, or how can I use another method to encode this base64 string? Thanks a lot everyone
    d
    • 2
    • 3
  • react
    h

    helpful-midnight-94669

    02/15/2023, 4:07 PM
    What is the best approach to test react js (and the like) generated html which often without id, name or tag and uses a lot of flexbox to hide things?
    l
    e
    • 3
    • 4
  • Problems with run Cypress without sudo.
    c

    clean-daybreak-15051

    02/15/2023, 4:15 PM
    Firstly i installed node and cypress via sudo (don't ask why), then i removed it and reinstall node via brew, and tried to install cypress without sudo. it installed but i can't run in without sudo command. I uninstalled cypress previously via -
    npm uninstall --save-dev cypress
    but seems like it doesn't work 🧐 Any advice how to uninstall cypress fully or give him permissions.
    • 1
    • 1
  • ASPX & Cypress
    l

    lively-lawyer-22558

    02/15/2023, 6:40 PM
    Hello all, I have quite an interesting issue with some tests I am trying to develop. There is this portal/tool that was written ages ago use APSX web forms and it's giving me some trouble when trying to interact with it in Cypress. The problem has been boiled down to a variable in the source code. Without making this initial post too long, what would cause a website to run normally without Cypress vs with Cypress? Like, is there some sort of sandbox that Cypress does all of it's operations that could possibly interfere with the source code of the site its testing on?
    m
    • 2
    • 2
  • Electron browser by default instead of Chrome
    f

    famous-energy-17408

    02/15/2023, 8:10 PM
    It seems that with the latest update, the Cypress app now launches the Electron browser by default instead of Chrome, as it did before. Is there a way to switch it back to using Chrome by default?
    m
    r
    • 3
    • 3
  • Target cannot be null or undefined after cy.get('table')
    c

    clever-night-39043

    02/16/2023, 6:58 AM
    Hi All I have this issue that cypress can get a table, but after that whether I do assertion like should or read the content, it keeps saying
    Target cannot be null or undefined
    . In cypress log, it shows something like:
    Copy code
    get table#groupsGrid_content_table
    assert expected <table#groupsGrid_content_table.e-table> to be visible
    "Timed out retrying after 4000ms: Target cannot be null or undefined."
    The
    get
    step passed but
    should
    part failed. How can I fix it? Thanks,
    • 1
    • 1
  • How to Set Content-type as Json in Cy.Request for POST API
    i

    incalculable-rainbow-43330

    02/16/2023, 7:44 AM
    I Tried to call Cy.Request for Post API and i tried to send my Header as 'Content-Type': 'application/json; charset=utf-8' but in the request its sending "content-type": "application/x-www-form-urlencoded", something is overriding this so can any one help me how to set content-type Note: for Get its working fine Error im getting is
    e
    • 2
    • 5
  • How to select PDF drop down button from print popup by cypress
    f

    flaky-iron-16108

    02/16/2023, 12:39 PM
    in my testing application after click on download PDF using cypress , typescript getting below window which is not a browser popup. unable to detect any element using cypress locator as it is not a browser popup. I need to select "save as PDF" by click on PDF drop-down button present in the popup. Unable to perform any action on PDF drop-down button.
    e
    • 2
    • 10
  • Assertions not being shown?!
    a

    abundant-alarm-34669

    02/16/2023, 1:22 PM
    I have an issue if somebody can help... My assertions are not being shown even tho I have a lot, yesterday same code it was working fine...
    e
    • 2
    • 1
  • How can i listen to all requests, and if it was not handled by intercepted throw a error
    i

    important-horse-22426

    02/16/2023, 5:58 PM
    Something like dynamic list of allowed requests. And bonus: if some request for certain endpoint was made more than necessary fail test
    g
    • 2
    • 1
  • Processing private fields in a node_modules dependency
    w

    witty-zebra-42624

    02/16/2023, 6:52 PM
    Hi! I have been trying to customize webpack configuration to transpile a dependency that uses private fields, but no matter what I pass to
    '@cypress/webpack-preprocessor';
    Cypress fails with a compilation error. Currently I have:
    Copy code
    ts
    import { defineConfig } from 'cypress';
    import { nxE2EPreset } from '@nrwl/cypress/plugins/cypress-preset';
    import * as wp from '@cypress/webpack-preprocessor';
    
    export default defineConfig({
      e2e: {
        setupNodeEvents(on, config) {
          const webpackOptions = {
            resolve: {
              extensions: ['.ts', '.js'],
            },
            module: {
              rules: [
                {
                  test: /\.ts/,
                  include: /node_modules/,
                  loader: 'babel-loader',
                  options: {
                    presets: [
                      ['@babel/typescript'],
                      ['@babel/preset-env', { targets: 'defaults' }],
                    ],
                    // presets: ['@babel/typescript', '@babel/preset-env']
                  },
                },
              ],
            },
          };
    
          on('file:preprocessor', wp({ webpackOptions }));
    
          return config;
        },
        ...nxE2EPreset(__dirname),
      },
    });
    It throws this error:
    Copy code
    Error: Webpack Compilation Error
    Module parse failed: 'import' and 'export' may appear only with 'sourceType: module' (1:0)
    You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
    > import './commands';
    | import { configure } from '@testing-library/cypress';
    Even just using
    webpackOptions: undefined
    it breaks the entire configuration. All the docs says that it provides the default configuration, but it seems that something else provides more options. Any idea how to setup this? Thanks!
    b
    • 2
    • 1
  • Cypress tutors please help...
    c

    cold-author-79999

    02/16/2023, 7:05 PM
    cy.get(
    table tr td:nth-child(5):contains(${tenant})
    ) .parents("tr") .filter((k, tr) => { return tr.children[0].innerText === house; }) .filter((k, tr) => { return tr.children[1].innerText === plot; }) .find("[data-test-id='options-wrapper']") .click(); return cy .get("#my-requests-table tbody tr") .filter(
    :has(td:nth-child(3):contains(${p3}))
    ) .filter(
    :has(td:nth-child(4):contains(${p4}))
    ) .filter(
    :has(td:nth-child(2):contains(${p2}))
    ) .filter(
    :has(td:nth-child(1):contains(${p1}))
    ) .filter(
    :has(td:nth-child(5):contains(${p5}))
    ); Can you explain the use of filters in each of these scenario?which is the right usage of filter?
    • 1
    • 1
  • How can I ignore all third party API fetch requests?
    s

    steep-country-21216

    02/16/2023, 8:45 PM
    Do I need to put the interception inside of beforeEach() or can I just put interceptions inside of an it block? Basically i am curious if I have to run this on every single test if a subsequent API call happens in another spec
    e
    • 2
    • 5
  • Websocket connection failed
    a

    aloof-dusk-92239

    02/17/2023, 7:38 AM
    Hey, when starting cypress tests in electron everything works ok, firing up in the browser throws an error on the console in a loop:
    Copy code
    shell
    WebSocket connection to 'ws://localhost:PORT/__socket/?EIO=4&transport=websocket' failed
    Does anyone know how to solve this problem?
    f
    • 2
    • 1
  • session() into blank page
    d

    dazzling-midnight-17560

    02/17/2023, 8:13 AM
    Hey there, Got an issue trying to transit from classic login to session's type. After my session is created, i got a blank page on all my tests. Prior the switch, it was all working. Am i missing something? Cypress.Commands.add("login", () => { const username = "xxx" const pwd = "xxx" cy.session([username, pwd], () => { cy.visit(routes.URL_BASE + "/login"); const loginForm = utils.getCypressComponentByDataId(components.LOGIN_FORM); const usernameInput = utils.getCypressComponentByDataId( components.LOGIN_FORM_USERNAME_INPUT ); const passwordInput = utils.getCypressComponentByDataId( components.LOGIN_FORM_PASSWORD_INPUT ); const submitButton = utils.getCypressComponentByDataId( components.LOGIN_FORM_BUTTON_SUBMIT ); usernameInput.type(username) passwordInput.type(pwd) submitButton.click() })
  • Storybook Cypress Component Tests conflict
    l

    little-byte-59792

    02/17/2023, 9:35 AM
    If we install @storybook/builder-webpack5 or @storybook/manager-webpack5 Component test stop working until we remove these. Any ideas?
  • Cypress.Commands.overwriteQuery: how to check if the command has prevSubject?
    k

    kind-lock-48901

    02/17/2023, 11:06 AM
    I’m trying to overwrite the
    .contains()
    command on
    Cypress v12.6.0
    with the following requirements: - search within the parent selector if the command has
    prevSubject
    , e.g.
    cy.get(selector).contains(content)
    - if the command doesn’t have
    prevSubject
    -> use default selector. How can I check if
    .contains()
    has a prevSubject and get its value? Thanks in advance!
  • Word to word testing
    e

    elegant-ghost-26278

    02/17/2023, 12:15 PM
    Wanted to know if we can do a word to word testing For example I have a csv file in which i have all the words stored and now i want to match each column with that on the website
    s
    e
    • 3
    • 11
  • Auth0 login page appears even though programmatic login was successful
    l

    loud-dinner-94998

    02/17/2023, 2:43 PM
    I was hoping you guys could lend me a hand here. The company I work at has a hub page with a product grid where if you click on a button it will take you to that product. The hub page is hub.com Any product you click on that is on the hub page's product grid will take you to hub.com/productname Access to hub.com and all products is granted through Auth0 authentication. In Cypress we have a
    before()
    hook that does the following:
    Copy code
    before(() => {
      cy.restoreLocalStorage();
      cy.loginAndRedirect();
      cy.saveLocalStorage();
    This is `loginAndRedirect()`:
    Copy code
    Cypress.Commands.add('loginAndRedirect', () => {
      Cypress.log({ name: 'log in with Auth0' })
      const authVariables = getAuth0Variables();
    
      const username = authVariables.username;
      const password = authVariables.password;
      const audience = authVariables.audience;
      const scope = 'openid profile email'
      const client_id = authVariables.client_id;
      const client_secret = authVariables.client_secret;
    
      return cy.request({
        method: 'POST',
        url: `${authVariables.url.replace(/\/+$/, "")}/oauth/token`,
        body: {
          grant_type: 'password',
          username,
          password,
          audience,
          scope,
          client_id,
          client_secret,
        },
      }).then(({ body: { access_token, expires_in, id_token } }) => {
        localStorage.setItem('access_token', access_token);
        localStorage.setItem(`@@auth0spajs@@::${client_id}::${audience}::${scope}`, JSON.stringify({
          body: {
            client_id,
            access_token,
            id_token,
            scope,
            expires_in,
            decodedToken: {
              user: jwt_decode(id_token),
            },
          },
          expiresAt: Math.floor(Date.now() / 1000) + expires_in,
        }))
        return cy.visit('/?cypress');
      });
    });
    • 1
    • 1
  • How can I properly stub an API request with cy.intercept
    s

    steep-country-21216

    02/17/2023, 7:17 PM
    I am having trouble on stubbing the API requests in my test.
    e
    g
    r
    • 4
    • 4
  • I get browser not supported when I "npm run test"
    l

    limited-yacht-64327

    02/18/2023, 3:24 AM
    I am new to react and I am writing tests for my application, but when i enter the command "npm run test" i get this message
    Copy code
    > client@0.0.0 test
    > cypress run --browser chrome --e2e
    
    Can't run because you've entered an invalid browser name.
    
    Browser: chrome was not found on your system or is not supported by Cypress.
    
    Cypress supports the following browsers:
     - electron
     - chrome
     - chromium
     - chrome:canary
     - edge
     - firefox
    
    You can also use a custom browser: https://on.cypress.io/customize-browsers
    
    Available browsers found on your system are:
     - electron
    Can't run because you've entered an invalid browser name.
    
    Browser: chrome was not found on your system or is not supported by Cypress.
    
    Cypress supports the following browsers:
     - electron
     - chrome
     - chromium
     - chrome:canary
     - edge
     - firefox
    
    You can also use a custom browser: https://on.cypress.io/customize-browsers
    
    Available browsers found on your system are:
     - electron
    this is weird because i have chrome installed and it is up to date, cypress is also up to date
    w
    e
    • 3
    • 2
  • Prevent Cypress from failing the test when having an uncaught exception
    f

    fresh-shampoo-23978

    02/18/2023, 7:01 AM
    Hi, I'm new to Cypress. I wanna prevent Cypress from failing the test when having an uncaught exception. How can I do that? This is my code. However, It isn't working
  • Asynchronous writing and getting values in variables
    a

    aloof-airport-25580

    02/19/2023, 11:52 AM
    Greetings. I have needs that I don't understand how to solve without using a big .then() schema. First need: Get a csrf token and PHPSESSID so that they can be used in further test steps for API requests; The second need is to store the values of the elements on page A, perform actions that will transfer to page B, compare values, perform actions that will transfer to page C and compare the values from page A there. I have read the following articles: https://glebbahmutov.com/cypress-examples/commands/connectors.html#cypress-commands-inside-the-callback https://docs.cypress.io/guides/core-concepts/introduction-to-cypress#Mixing-Async-and-Sync-code But unfortunately, I don't understand how I can write the code in such a way that it works, and in the future it would be possible to write sections into user-defined functions and reuse them in other files. I am attaching a file with an attempt to solve the first need. I get CSRF and PHPSESSID, but at the time of sending the request (and I need to make more than 10 of them), the variables do not have the necessary data. Please help me understand this code.
    g
    • 2
    • 2
  • Cypress test if element is covered
    f

    few-laptop-73260

    02/19/2023, 3:21 PM
    Hello! I have a React Native app with expo and I am trying to write a test for my app. I want to check if a text behind a drawer is being hidden by the drawer. I could not find any properties that would change when the drawer appears using the web version of the app, except a translation css property. However, I could see that when I try to click the text behind the drawer, it throws an error saying that the text is being covered. What I want is an assertion of this covered element. How can it be done?
    c
    • 2
    • 1
  • yml config returns: spec must be a string or comma-separated list
    p

    powerful-orange-86819

    02/20/2023, 11:08 AM
    Hi i'm trying to run specific specs in order by the YAML file in the pipeline This is part of my YAML file that i'm trying to executed:
    Copy code
    yml
    stages:
      - test
    test:
      image: cypress/browsers:node16.17.0-chrome106
      parallel:
        matrix:
          - SUITES: "suite1.spec.js, suite2.specjs, suite3.spec.js"
    the CI Lint validator says is correct but cypress returns an error. Anyone know about this error?
    a
    n
    • 3
    • 14
  • Network call response is not showing expected response in Cypress Test
    q

    quaint-airplane-96634

    02/20/2023, 11:34 AM
    When my test is running in cypress browser, One the XHR request is showing response in junk characters that leads to unexpected output . How do I deal with such issue.?
  • How can I avoid "waiting for page load" after clicking a download link?
    f

    faint-ocean-92094

    02/20/2023, 4:57 PM
    I have a test where I download a PDF file through a button. The button simply downloads the file, no reload, no prompt, nothing. For some reason, when I click this link, the file is downloaded (I can see it on my downloads folder) but the test keeps waiting for Page to Load, when nothing is actually loading. Since the page did not trigger the load event, my test times out after 60 secs. The problem is that, as mentioned, nothing is loading. no resources or anything. Why is it waiting for page to load, or how can I avoid/interrupt this validation?
    n
    h
    • 3
    • 9
  • Issues with Cypress 12.5.1 and origin/require (ng project)
    m

    melodic-artist-76036

    02/20/2023, 6:11 PM
    I have a strange issue which I can't even explain properly. I am using
    cy.origin
    and
    require
    to import dependencies. Those dependencies are local modules (page objects) which I need for assertions. Locally, everything works like a charm, but on CI I get this error:
    Error: Error: ENOENT: no such file or directory, open '/tmp/cypress/webpack-preprocessor/36c17fa865a97b9d11c9436638e044d7/cross-origin-cb-948eb7e9dc3ceb4e5222da0c9c591d18.js'
    Now before posting the whole setup, does anyone have an idea what could be the issue here? It seems it can not find the sources required for cross origin callbacks.
    a
    h
    s
    • 4
    • 7
  • Tests randomly return bad XRef Entry after readFileSync
    f

    faint-ocean-92094

    02/20/2023, 10:46 PM
    I need to verify the contents of a PDF. For this I've created a task: on cypress.config.js I have:
    Copy code
    const pdf = require('pdf-parse');
    
    getPdfContent(pdfName) {
     return pdf(fs.readFileSync('cypress/downloads/' + pdfName))
    }
    On my test I call
    Copy code
    cy.task("getPdfContent", "Test PDF File.pdf").then(content => {
      expect(content.text).to.have.string("Testing content")
     })
    Sometimes the test passes like a charm, but sometimes I get the error bad XRef Entry. For what I have read this is a problem with the PDF file but the PDF file I download is fine. Furthermore if I rerun the same process with the same file, it works fine. So it looks like the problem is what readFileSync is passing to the pdf() function. My theory is that the process is not finished when pdf() wants to parse it, as it only happens sometimes. But I can't figure out what is going on. Could it be that readFileSync is not working correctly everytime? Is there a way to verify or wait for it to finish before calling pdf() on it?
    n
    • 2
    • 4
  • I am testing one API with different users and noticing that first test is always taking more time
    s

    silly-student-97216

    02/21/2023, 5:18 AM
    Hi, I am testing one API with multiple users say 10 different users. I noticed that my first test always take more than 1s to return the response but the rest 9 tests return response with 0.5s. How can I deal with such issue.
1...8910...26Latest