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

    alert-chef-12385

    10/02/2022, 4:37 PM
    Hi, any opinion on https://discord.com/channels/755913899261296641/1025821108227801138 (I did mistake and created new thread)
  • s

    stale-wire-41120

    10/02/2022, 5:29 PM
    please help me out as i am trying to read from excel file
  • s

    stale-wire-41120

    10/02/2022, 5:33 PM
    module.exports = defineConfig({ e2e: { setupNodeEvents(on, config) { on("task", { generateJsonFromExcel: generateJsonFromExcel, }); return config; function generateJsonFromExcel(args) { const wb = xlsx.readFile(args.excelFilePath, { dataNF: "mm/dd/yyyy" }); const ws = wb.sheets[args.sheetName]; return xlsx.utils.sheet_to_json(ws, { raw: false }); } }, }, })
  • s

    stale-wire-41120

    10/02/2022, 5:34 PM
    it.only("read from excel", () => { cy.visit('https://www.facebook.com/') const excelFilePath = "C:/Users/princ/Desktop/cred.xlsx"; const sheetName = "cred"; cy.task("generateJSONFromExcel", { excelFilePath, sheetName }).then((user) => { cy.get('[data-testid="royal_email"]').type(user[0].username) cy.get('[data-testid="royal_pass"]').type(user[0].password) cy.get("#login-button").click() }) })
  • n

    narrow-artist-87113

    10/02/2022, 6:17 PM
    Can anyone tell me, how can i declare environment variables in cypress? Like which file, where to save and store etc
  • m

    mysterious-belgium-25713

    10/02/2022, 6:17 PM
    Please read the cypress docs: https://docs.cypress.io/guides/guides/environment-variables#Option-1-configuration-file
  • m

    mysterious-belgium-25713

    10/02/2022, 6:21 PM
    Hi, you have typo in your files. So in your test you call it generateJSONFromExcel, where JSON is full capital. in your task file its Json. Here is the corrected config file
    Copy code
    js
    export default defineConfig({
      e2e: {
        async setupNodeEvents(on, config) {
          on("task", { generateJSONFromExcel });
          return config;
          function generateJSONFromExcel(args) {
            const wb = xlsx.readFile(args.excelFilePath, { dataNF: "mm/dd/yyyy" });
            const ws = wb.sheets[args.sheetName];
            return xlsx.utils.sheet_to_json(ws, { raw: false });
          }
        },
      },
    });
  • m

    mysterious-belgium-25713

    10/02/2022, 6:58 PM
    Your error now is no such file or directory
  • m

    mysterious-belgium-25713

    10/02/2022, 6:58 PM
    So the task is working
  • s

    stale-wire-41120

    10/02/2022, 7:00 PM
    @mysterious-belgium-25713 is there any other way to give path or it is correct?
  • m

    mysterious-belgium-25713

    10/02/2022, 7:06 PM
    Yeah because its windows you need to do it like this.
    Copy code
    js
    C:\\Users\\princ\\Desktop\\cred.xlsx
    But I dont know how the xlsx library works so with my current knowledge i cannot help you with errors.
  • n

    narrow-artist-87113

    10/03/2022, 6:16 AM
    Has anyone tried to Sign in with Google or GitHub etc using cypress
  • n

    narrow-artist-87113

    10/03/2022, 6:16 AM
    ?
  • v

    victorious-queen-73209

    10/03/2022, 7:05 AM
    Hello All
  • v

    victorious-queen-73209

    10/03/2022, 7:05 AM
    Can anybody help me out for code coverage thing?
  • v

    victorious-queen-73209

    10/03/2022, 7:16 AM
    Hello All Can anybody help me out?
  • v

    victorious-father-41976

    10/03/2022, 8:34 AM
    Has anyone tried to Sign in with Google
  • v

    victorious-queen-73209

    10/03/2022, 8:38 AM
    Combine Code coverage of karma unit test and cypress integration test
  • s

    stale-wire-41120

    10/03/2022, 8:41 AM
    Thread
  • b

    brainy-psychiatrist-91653

    10/03/2022, 8:50 AM
    Hi All, I am writing API tests using Cypress 6.4.0 & TypeScript where I need to upload a pdf file in the request body. My code for the request is: public async createAssetDocTest() { let url = sharedData.createAsset_url + sharedData.assetA; let response = await fetch(url , { method: 'POST', body: await requestbody.createAssetDocBody(), headers: { Authorization: sharedData.bearer + " " + adminTokenValue, Accept: sharedData.accept, 'Content-type': sharedData.createDoc_contenttype, }, } ); logging(); expect(response.status).to.equal(200); My code for the request body is: public async createAssetDocBody(): Promise { const file = sharedData.doc; cy.fixture(file).then((pdfDoc) => { Cypress.Blob.binaryStringToBlob( pdfDoc, sharedData.contentTypeValue ).then(async (blob: string | Blob) => { const formData = new FormData(); formData.set(sharedData.document, blob, file); const body = { formdata: { document: { value: pdfDoc, options: { filename: sharedData.document, contentType: null, }, }, }, }; return body; }); }); } However, the file does not upload the file & the request fails with error 400. Is there a better way to upload files in the body of the POST request?
  • m

    mammoth-sugar-52290

    10/03/2022, 9:08 AM
    Hello, very good, I don't know if this is the right place to comment on this. I am QA automation in Spain and I have a problem that I don't know if any of you have had. I'm testing a website and when I go from one screen to another, it gets through but Cypress crashes and I can't continue doing anything. However, with selenium I can get to test that page.
  • b

    brainy-psychiatrist-91653

    10/03/2022, 9:14 AM
    Hey, what version of Cypress are you using?
  • l

    lemon-elephant-47278

    10/03/2022, 9:23 AM
    Hi, my cypress testcases are working fine on local, but sometime Jenkins pipeline return timeout. Timeout issues are spradic. Does anyone facing this issue?
  • v

    victorious-queen-73209

    10/03/2022, 9:33 AM
    @lemon-elephant-47278 - what commands are you using for local and Jenkins? Is your command contains any dev server to be start?
  • l

    lemon-elephant-47278

    10/03/2022, 9:50 AM
    We are using cypess.run() with some options, for both local as well as Jenkins Earlier it used to work fine, but from last week or so it started giving us this issue.
  • m

    mammoth-sugar-52290

    10/03/2022, 10:02 AM
    Hi @brainy-psychiatrist-91653 thanks for replying. my version is this "cypress": "10.3.1", And what happens is that it stays like this and the page loads but I can't do anything anymore, I've read somewhere that it could be a memory problem?
  • v

    victorious-queen-73209

    10/03/2022, 10:18 AM
    Is any version got upgraded like node, angular or cypress etc.?
  • s

    stale-wire-41120

    10/03/2022, 10:20 AM
    i am using cypress-failed-log plugin but showing this error ,please help me out
  • m

    mysterious-belgium-25713

    10/03/2022, 11:01 AM
    If i read the documentation for this plugin it's not being used as a Cypress task. This will work out of the box without needing to use cy.task. Please read the documentation on the usage.
  • m

    mysterious-belgium-25713

    10/03/2022, 11:02 AM
    https://github.com/bahmutov/cypress-failed-log
1...160161162...252Latest