I learnt cypress and playwright from your playlist and master class too….and I landed software tester job in Germany..many thanks to you….may god bless u….keep up the good work…🙂🙂🙂🙂🙂🙂
Thank you so much Raghav, this 4 video playlist was very helpful :) I learned cypress from 0 thanks to you ! Let me ask, I think you did not cover topics below right? These were in the content of this playlist as far as I understand, so sad you did not have chance to cover them all . "API Testing Custom Commands Cypress Studio Cypress Dashboard Cypress BDD Framework Database Integration Git Jenkins" If you will find chance to cover them it will be much appreciated ! Will be looking forward ! Thank you so much for this content againn! 💕
Hi Raghav, thank you for such an informative course on Cypress! It was just what I needed for my job! I'll soon be looking to implement some accessibility packages and your masterclass has given me the comfort to cover those topics!
Sir please make videos on latestsversion of cypress with cucumber installation. I am not able to install an use it in my system and also not able to find the related videos on other channels every video on channels are of old version cypress with cucumber.
Awsome tutorial great work sir really appreciated.and you mentioned each steps in description it will be very helpfull. cannot say only thanks. and where did you covered cucumber with cypress pls let me know
Hi Raghav, wonderful explanation of cypress. Learned so many things. Normally, i m able to handle the table. How to handle a table after applying filter?
Hi Trupti, Handling a table after applying a filter in Cypress can be done by using the .filter() method in conjunction with the .eq() method. Here's an example of how you can select a specific row in a table after applying a filter: /* cy.get("table tr").filter(":contains('Filter Text')").eq(0).click() */ This code will select the first row of the table that contains the text "Filter Text" in any of its cells You can also use the filter method with attribute and value, for example: /* cy.get("table tr").filter("[data-name='Filter Text']").eq(0).click() */ This code will select the first row of the table that contains the text "Filter Text" in its "data-name" attribute. It's also possible to chain multiple filters and eq method to select the specific row, you can also use the .each() method to iterate over the filtered rows and perform additional actions on them. It is important to note that the code above assumes that the table structure and the filter mechanism of the website is already known, and the selectors used to select the table rows are correct.
Thank you @RaghavPal for your detailed explanation. It was very useful for me. I didn't see the CI/CD pipeline implementation with jenkins in this course. Do we have that details anywhere added?
Hi Raghav, Thanks much for this awesome tutorial and all the others that you have been providing. May I kindly request you to also add a tutorial on Cypress Debugging?
Hi Raghav , I had watch all video on cypress . Thanks a lot for your effort and time . Can you please take a class for cypress cucumber BDD with version above 10 as this seems impossible to understand . To many error's coming , I have followed many videos but no idea where I am going wrong , I checked line by line and file by file . Please make one video for cypress with cucumber BDD . Thanks again for your efforts and time .
Hi Raghav, I finished this tutorial. It was great! I only have 1 question, when we created our Login_page.js, this is the only test that doesn't end in cy.js. was this an oversite? Thanks again.
Hello Raghav, I really like your videos. Do you have some other course on Cypress that includes more concepts( even if it has to be paid). I really like the way you are explaining. Please let me know if exist, I would like to take it. Thanks
Hi Raghav, can you please upload a series for Cypress Framework with latest cypress version ? And including how to explain cypress framework in Interviews
Hi Raghav, would be nice to have BrowserStack and Jenkins implemented in our testing framework. Any chance you create a video on these 2 topics? Thanks again for your great videos :) Much appreciated :)
Hi Reghav, would be nice get tutorial video of Reading Data from Excel in Cypress. Please post if you can. Thanks for your great videos :) Much appreciated :)
Hi Raghav, Could you please create a video or reply here on how to go to website and click on Reviews and verify/validate few good and bad reviews using assertions
Hi Raghav, this course is awesome! In one of the videos you said you will cover Cypress with Cucumber BDD, but I did not see it. Am I missing it somewhere or that is the video that is coming .. ? Thanks for doing this !
Hello Sir, 1)Can we handle error from Cypree? Using try catch block as we use in selenium 2)How to write condition testing in cypress? Eg.if wring password give need to check error text element displayed or not ..in that case how to write condition using if ,else as we do in Selenium
Archana 1) Handling Errors in Cypress Cypress doesn’t use try-catch like Selenium. Instead, use .then() and .catch() for error handling: cy.get('input[name="username"]') .type('wrongUser ') .then(() => { cy.get('input[name="password"]').type('wrongPassword'); }) .catch((error) => { cy.log('An error occurred:', error); }); 2) Conditional Testing in Cypress You can implement conditional logic using .then(): cy.get('input[name="username"]').type('wrongUser '); cy.get('input[name="password"]').type('wrongPassword'); cy.get('button[type="submit"]').click(); cy.get('.error-message').then(($error) => { if ($error.is(':visible')) { if ($error.text() === 'Invalid credentials') { cy.log('Correct error message displayed'); } else { cy.log('Unexpected error message'); } } else { cy.log('Error message is not displayed'); } }); This checks if the error message is visible and verifies its text. -
@RaghavPal Thanks Sir for second point incase if I don't get error then won't it fail the script In line cy.get('.error-message') .?.can we make script more flexible, like if error occurs it should check ,else it should move on to next line?
Yes, you can make your Cypress script more flexible by using conditional logic to check for the presence of the error message before attempting to access it. You can do this by using the .should() assertion combined with the .then() method to handle the case where the error message might not be present.. Here’s how you can modify your script to check for the error message only if it exists, and to continue executing the next steps if it doesn’t: cy.get('input[name="username"]').type('wrongUser '); cy.get('input[name="password"]').type('wrongPassword'); cy.get('button[type="submit"]').click(); // Check if the error message exists cy.get('.error-message').then(($error) => { if ($error.length) { // Check if the error message exists // Error message exists, check its visibility and text if ($error.is(':visible')) { if ($error.text() === 'Invalid credentials') { cy.log('Correct error message displayed'); } else { cy.log('Unexpected error message'); } } else { cy.log('Error message is not visible'); } } else { // No error message, continue with the next steps cy.log('No error message displayed, proceeding with next steps...'); // Add your next steps here } }); -
Vikum In case you need to setup Jenkins or Pipeline.. can check my videos here - automationstepbystep.com/ here is a step-by-step process of connecting your Cypress tests to a DevOps CI/CD pipeline using Jenkins. Prerequisites: 1. You have Cypress installed and set up in your project. 2. You have a Jenkins server set up and running. 3. You have a basic understanding of Jenkins and CI/CD pipelines. Step 1: Create a Jenkins Job 1. Log in to your Jenkins server and click on "New Item" to create a new job. 2. Enter a name for your job, select "Freestyle project", and click "OK". 3. In the job configuration page, scroll down to the "Source Code Management" section and select "Git" (or your preferred version control system). 4. Enter your repository URL, credentials, and branch information. Step 2: Install Cypress and Dependencies 1. In the "Build Environment" section, click on "Add build step" and select "Execute shell". 2. In the command field, enter the following command to install Cypress and its dependencies: ``` npm install cypress ``` Step 3: Run Cypress Tests 1. Click on "Add build step" again and select "Execute shell". 2. In the command field, enter the following command to run your Cypress tests: ``` npx cypress run ``` This command will run your Cypress tests using the `cypress run` command. Step 4: Archive Test Results 1. Click on "Add post-build action" and select "Archive the artifacts". 2. In the "Files to archive" field, enter the following path to archive your test results: ``` cypress/results/*.xml ``` This will archive the JUnit XML reports generated by Cypress. Step 5: Configure Jenkins to Publish Test Results 1. Click on "Add post-build action" again and select "Publish JUnit test result report". 2. In the "Test report XMLs" field, enter the following path: ``` cypress/results/*.xml ``` This will publish your test results to Jenkins. Step 6: Save and Run Your Job 1. Click "Save" to save your job configuration. 2. Click "Build Now" to run your job. Once the job is complete, you should see your Cypress test results published in Jenkins. You can then configure your pipeline to trigger on code changes, schedule builds, and more. That's it! You've successfully connected your Cypress tests to a DevOps CI/CD pipeline using Jenkins. --
I think you have missed to add masterclass 3 for cypress. Can you please add that video or if it is already added can you please provide the link. Thanks in advance 👍
Sure, here are some resources for learning how to use custom commands and cy.session in Cypress: Cypress Custom Commands: This is the official documentation for creating and using custom commands in Cypress. It includes examples and explanations of how to create custom commands, as well as best practices for using them effectively. You can find it here: docs.cypress.io/api/cypress-api/custom-commands Cypress Session: This is the official documentation for using cy.session in Cypress. It explains how to use cy.session for logging in and maintaining state across tests. You can find it here: docs.cypress.io/api/commands/session Cypress Recipes: This is a collection of useful code snippets and tips for working with Cypress, including custom commands and cy.session. You can find it here: github.com/cypress-io/cypress-example-recipes I hope these resources help you learn more about using custom commands and cy.session in Cypress!
Hi Raghav, I need your guidance. I wrote a script in Cypress to find duplicate entries in PDFs. It works when I have one file in fixtures. Now, I want to take it a step further. I want to create a folder, put all my PDF files there, and dynamically read them using their file extensions or other annotations. Then, I want to log the findings in a report with the corresponding file names so that the user can easily see which file has duplicate entries. Can you help me with this?
Noor Here are the steps on how to create a Cypress script to find duplicate entries in PDFs and log the findings in a report with the corresponding file names: 1. Create a folder to store your PDF files. 2. Put all your PDF files in the folder. 3. Create a new Cypress script file. 4. Import the following modules: ```javascript import fs from 'fs'; import pdfjsLib from 'pdfjs-dist'; ``` 5. Define a function to read a PDF file: ```javascript function readPDF(filePath) { return new Promise((resolve, reject) => { fs.readFile(filePath, (err, buffer) => { if (err) { reject(err); return; } const pdfDoc = pdfjsLib.getDocument(buffer); pdfDoc.promise.then(resolve); }); }); } ``` 6. Define a function to find duplicate entries in a PDF file: ```javascript function findDuplicateEntries(pdfDoc) { const pages = pdfDoc._pdfInfo.numPages; const entries = []; for (let i = 1; i textContent.items.map(item => item.str).join(' ')); entries.push(text); } const uniqueEntries = new Set(entries); const duplicateEntries = entries.filter(entry => !uniqueEntries.has(entry)); return duplicateEntries; } ``` 7. Define a function to log the findings in a report: ```javascript function logFindings(duplicateEntries, fileName) { const reportFile = fs.createWriteStream('report.txt'); reportFile.write(`File name: ${fileName} `); duplicateEntries.forEach(entry => { reportFile.write(`Duplicate entry: ${entry} `); }); reportFile.end(); } ``` 8. Write the main test case: ```javascript it('should find duplicate entries in PDFs', async () => { const pdfFiles = fs.readdirSync('./pdfs'); for (const pdfFile of pdfFiles) { const filePath = `./pdfs/${pdfFile}`; const pdfDoc = await readPDF(filePath); const duplicateEntries = await findDuplicateEntries(pdfDoc); if (duplicateEntries.length > 0) { logFindings(duplicateEntries, pdfFile); } } }); ``` 9. Run the Cypress script: ``` npx cypress run ``` This will generate a report.txt file with the list of duplicate entries for each PDF file. I hope this helps
@@RaghavPal Sir I have one doubt...in Cypress using mochawesome report...if I am running a test case...each time when I run..it will generate the report ah?....or only if I gave the comment for generate report in the command prompt terminal it will generate report ah? And also if I'm generation a report for a test case at time 11 ....and once again at 12...it will give separate report or it will overwrite it?
Hello, I have a question. In Cypress, when the test comes to an end, the chrome window (and other bowsers if used) closes and returns to the main page, where we have Specs, Runs, Settings etc. How to keep it in the chrome window?
Hi SineQuaNon, In Cypress, you can use the cy.end() command to end a test and keep the browser window open. This command ends the currently running test but keeps the browser window open, allowing you to interact with the application manually or run further tests. For example: describe('My test', () => { it('does something', () => { // ... test code here cy.end() // end the test but keep the browser window open }) }) Alternatively, you can use the cy.debug() command to pause the test and open the browser's developer tools. This allows you to interact with the application and debug any issues. describe('My test', () => { it('does something', () => { // ... test code here cy.debug() // pause the test and open the browser's developer tools }) }) cy.end() and cy.debug() can only be used within a test and not in before or after hooks.
Hi, you can use the cy.get() command to select the file input element, and then use the cy.attachFile() command to upload a file. Here is an example: /* cy.get('input[type=button]').attachFile('path/to/file.txt') */ Make sure the element is visible and active (not hidden)
Hi Azima, not too sure on this, This can be app side issue, this can help - stackoverflow.com/questions/57421582/typeerror-object-prototype-may-only-be-an-object-or-null-undefined-angular-8
Can u make a video on cy.session as i am new not able to follow it ,like i have test 1,2,3,4 under test scenario when i execute test case 1,2 executes but user automatically loges out on test 3,4 i am stuck here ,it would be great if you could help me with some example
Hi Raghav! Thank you for your tutorials. I followed Masterclass 1-4 here. Then I went to the following video for HTML reports, where you used cypress.json file to add configuration. th-cam.com/video/J9AHVKNDkDU/w-d-xo.htmlfeature=shared But in my project I do not have cypress.json file. Could you tell me how I can get this file to add configuration please?
Wayez The cypress.json file is no longer needed in the latest version of Cypress. This will help: Using a cypress.json configuration file is no longer supported. Replace this configuration file with a cypress.config.js, cypress.config.ts, cypress.config.cjs or cypress.config.mjs file. docs.cypress.io/guides/references/changelog docs.cypress.io/guides/references/configuration
Hi Raghav , I followed your all 4 tuturial sessions. Thank you for all your great videos 😃. I have done them with TypeScript. Only last one with File download I get 2 error messages. One " Try `npm i --save-dev @types/cypress-downloadfile` if it exists or add a new declaration (.d.ts) file containing `declare module 'cypress-downloadfile/lib/addPlugin';`ts(7016). P.S. I would like also to mention that my addPlugin in js extend type. Should I change/download addPlugin in ts extend type? How can I do that? I could not achieve that. The other error message. I have "require" red underlined "require('cypress-downloadfile/lib/downloadFileCommand')" when I write this in commond.ts file. Cannot find name 'require'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node` and then add 'node' to the types field in your tsconfig. I downloaded this npm i --save-dev @types/node. But it doesn't help me. I could not solve this issue all day. Could you pls. help me?
hey Raghav. it seems .attachFile ( ) function has been deprecated. I keep getting the "cy.get(...).attachFile is not a function error. ANy alternative?
cy.preserveOnce is not working for me.. If there is an alternative to cypress.cookies.preserveOnce in version 10 please share a link. If there is no video, please make one. Thank you very much.
Hi Habib, I will need to check, see if this helps - stackoverflow.com/questions/69605268/cypress-cookies-preserveoncesession-id-isnt-working-when-called-in-aftereac
I learnt cypress and playwright from your playlist and master class too….and I landed software tester job in Germany..many thanks to you….may god bless u….keep up the good work…🙂🙂🙂🙂🙂🙂
That's great Pallavi.. all the best
mostly while learning a new framework or tool i used to refer minimum three channels, but you are the best in explaining things..
Thanks a lot Susmitha. Humbled
Oh man! This wonderful tutorial got over before the API testing part. Craving for more now :) Thank you so much for creating these.
Thanks a lot
I'm looking forward to see your next video explaining API testing in Cypress. I really like your videos, and keep up with good work. Thanks
Thanks, will do Ivan
Thank you for your Cypress Beginner Tutorials videos. Indeed it was an informative one
Most welcome Rajith
Thank you so much Raghav, this 4 video playlist was very helpful :) I learned cypress from 0 thanks to you !
Let me ask, I think you did not cover topics below right?
These were in the content of this playlist as far as I understand, so sad you did not have chance to cover them all .
"API Testing
Custom Commands
Cypress Studio
Cypress Dashboard
Cypress BDD Framework
Database Integration
Git
Jenkins"
If you will find chance to cover them it will be much appreciated ! Will be looking forward ! Thank you so much for this content againn! 💕
I will plan Nursena
Can also check all Cypress lectures here - automationstepbystep.com/
Thank you for your Cypress Beginner Tutorials videos. This was very helpful and well organized.
Most welcome Nikolina
Hi Raghav, thank you for such an informative course on Cypress! It was just what I needed for my job!
I'll soon be looking to implement some accessibility packages and your masterclass has given me the comfort to cover those topics!
Most welcome
Sir please make videos on latestsversion of cypress with cucumber installation. I am not able to install an use it in my system and also not able to find the related videos on other channels every video on channels are of old version cypress with cucumber.
Thank you for your time and efforts ! as always your way of teaching is fascinating
You are very welcome Hazem
Thanks, Raghav for this wonderful session.
Most welcome Virendra
Awsome tutorial great work sir really appreciated.and you mentioned each steps in description it will be very helpfull. cannot say only thanks.
and where did you covered cucumber with cypress pls let me know
You are most welcome, yet to create a lecture on that
Hi Raghav, wonderful explanation of cypress. Learned so many things. Normally, i m able to handle the table. How to handle a table after applying filter?
Hi Trupti,
Handling a table after applying a filter in Cypress can be done by using the .filter() method in conjunction with the .eq() method.
Here's an example of how you can select a specific row in a table after applying a filter:
/*
cy.get("table tr").filter(":contains('Filter Text')").eq(0).click()
*/
This code will select the first row of the table that contains the text "Filter Text" in any of its cells
You can also use the filter method with attribute and value, for example:
/*
cy.get("table tr").filter("[data-name='Filter Text']").eq(0).click()
*/
This code will select the first row of the table that contains the text "Filter Text" in its "data-name" attribute.
It's also possible to chain multiple filters and eq method to select the specific row, you can also use the .each() method to iterate over the filtered rows and perform additional actions on them.
It is important to note that the code above assumes that the table structure and the filter mechanism of the website is already known, and the selectors used to select the table rows are correct.
@@RaghavPal Thanks a lot Raghav. It was really helpful. Thanks for your precious time. 😊
Thx Master for next session :) I go for your another Cypress list;)
Most welcome..
Thank you @RaghavPal for your detailed explanation. It was very useful for me.
I didn't see the CI/CD pipeline implementation with jenkins in this course. Do we have that details anywhere added?
Glad it was helpful Jansi. Okay, you can check the process in detail in my Jenkins playlists. can find all here - automationstepbystep.com/
Hi Raghav,
Thanks much for this awesome tutorial and all the others that you have been providing.
May I kindly request you to also add a tutorial on Cypress Debugging?
Sure, I will do
Thank you kindly for your content Raghav🙏and you look very handsome with mustache and beard 😍
So nice of you
thank you Raghav!
maybe are you going to make lesson about screenshot testing in cypress? :)
I will plan
Hi Raghav , will you be making a video to implement Cucumber in cypress in Cypress masterclass series?
I will plan Rahul
Hi Raghav ,
I had watch all video on cypress . Thanks a lot for your effort and time .
Can you please take a class for cypress cucumber BDD with version above 10 as this seems impossible to understand . To many error's coming , I have followed many videos but no idea where I am going wrong , I checked line by line and file by file . Please make one video for cypress with cucumber BDD .
Thanks again for your efforts and time .
I will try on it Praveen
Great Work, thank you a lot
Glad you liked it Eman
Hi Raghav, I finished this tutorial. It was great! I only have 1 question, when we created our Login_page.js, this is the only test that doesn't end in cy.js. was this an oversite? Thanks again.
Yes, correct. Also you can check the naming conventions if any or add in the configuration file
thanks a-lot for these, we are waiting for next video
You are most welcome, will try to add more
Hi Raghav , Nice video and loved it , when can we expect next set of videos on Cypress master class.
as of now I have created 4 parts, will upload if I create more videos, Will get notified if you have subscribed
Hello Raghav, I really like your videos. Do you have some other course on Cypress that includes more concepts( even if it has to be paid). I really like the way you are explaining. Please let me know if exist, I would like to take it. Thanks
Hi, can find all Cypress tutorials that I have created here - automationstepbystep.com/
Hi Raghav, can you please upload a series for Cypress Framework with latest cypress version ? And including how to explain cypress framework in Interviews
Hi Shubham
Sure, I will plan on this
Hi Raghav, would be nice to have BrowserStack and Jenkins implemented in our testing framework. Any chance you create a video on these 2 topics?
Thanks again for your great videos :) Much appreciated :)
Sure Nicolas
Hi Reghav, would be nice get tutorial video of Reading Data from Excel in Cypress. Please post if you can. Thanks for your great videos :) Much appreciated :)
Will do Samantha
Hi Raghav, Could you please create a video or reply here on how to go to website and click on Reviews and verify/validate few good and bad reviews using assertions
Hi I will work on this
Hi Raghav, this course is awesome! In one of the videos you said you will cover Cypress with Cucumber BDD, but I did not see it. Am I missing it somewhere or that is the video that is coming .. ? Thanks for doing this !
Hi Daniela, can check the Beginners Playlist here automationstepbystep.com/
Hello Sir,
1)Can we handle error from Cypree? Using try catch block as we use in selenium
2)How to write condition testing in cypress? Eg.if wring password give need to check error text element displayed or not ..in that case how to write condition using if ,else as we do in Selenium
Archana
1) Handling Errors in Cypress
Cypress doesn’t use try-catch like Selenium. Instead, use .then() and .catch() for error handling:
cy.get('input[name="username"]')
.type('wrongUser ')
.then(() => {
cy.get('input[name="password"]').type('wrongPassword');
})
.catch((error) => {
cy.log('An error occurred:', error);
});
2) Conditional Testing in Cypress
You can implement conditional logic using .then():
cy.get('input[name="username"]').type('wrongUser ');
cy.get('input[name="password"]').type('wrongPassword');
cy.get('button[type="submit"]').click();
cy.get('.error-message').then(($error) => {
if ($error.is(':visible')) {
if ($error.text() === 'Invalid credentials') {
cy.log('Correct error message displayed');
} else {
cy.log('Unexpected error message');
}
} else {
cy.log('Error message is not displayed');
}
});
This checks if the error message is visible and verifies its text.
-
@RaghavPal Thanks Sir
for second point incase if I don't get error then won't it fail the script In line cy.get('.error-message') .?.can we make script more flexible, like if error occurs it should check ,else it should move on to next line?
Yes, you can make your Cypress script more flexible by using conditional logic to check for the presence of the error message before attempting to access it. You can do this by using the .should() assertion combined with the .then() method to handle the case where the error message might not be present..
Here’s how you can modify your script to check for the error message only if it exists, and to continue executing the next steps if it doesn’t:
cy.get('input[name="username"]').type('wrongUser ');
cy.get('input[name="password"]').type('wrongPassword');
cy.get('button[type="submit"]').click();
// Check if the error message exists
cy.get('.error-message').then(($error) => {
if ($error.length) { // Check if the error message exists
// Error message exists, check its visibility and text
if ($error.is(':visible')) {
if ($error.text() === 'Invalid credentials') {
cy.log('Correct error message displayed');
} else {
cy.log('Unexpected error message');
}
} else {
cy.log('Error message is not visible');
}
} else {
// No error message, continue with the next steps
cy.log('No error message displayed, proceeding with next steps...');
// Add your next steps here
}
});
-
@RaghavPal wow thanks much sir for explaining in detail...
Hi Raghav
Do you have a video how to connect devOps CI/CD pipeline and Jenkin?
Vikum
In case you need to setup Jenkins or Pipeline.. can check my videos here - automationstepbystep.com/
here is a step-by-step process of connecting your Cypress tests to a DevOps CI/CD pipeline using Jenkins.
Prerequisites:
1. You have Cypress installed and set up in your project.
2. You have a Jenkins server set up and running.
3. You have a basic understanding of Jenkins and CI/CD pipelines.
Step 1: Create a Jenkins Job
1. Log in to your Jenkins server and click on "New Item" to create a new job.
2. Enter a name for your job, select "Freestyle project", and click "OK".
3. In the job configuration page, scroll down to the "Source Code Management" section and select "Git" (or your preferred version control system).
4. Enter your repository URL, credentials, and branch information.
Step 2: Install Cypress and Dependencies
1. In the "Build Environment" section, click on "Add build step" and select "Execute shell".
2. In the command field, enter the following command to install Cypress and its dependencies:
```
npm install cypress
```
Step 3: Run Cypress Tests
1. Click on "Add build step" again and select "Execute shell".
2. In the command field, enter the following command to run your Cypress tests:
```
npx cypress run
```
This command will run your Cypress tests using the `cypress run` command.
Step 4: Archive Test Results
1. Click on "Add post-build action" and select "Archive the artifacts".
2. In the "Files to archive" field, enter the following path to archive your test results:
```
cypress/results/*.xml
```
This will archive the JUnit XML reports generated by Cypress.
Step 5: Configure Jenkins to Publish Test Results
1. Click on "Add post-build action" again and select "Publish JUnit test result report".
2. In the "Test report XMLs" field, enter the following path:
```
cypress/results/*.xml
```
This will publish your test results to Jenkins.
Step 6: Save and Run Your Job
1. Click "Save" to save your job configuration.
2. Click "Build Now" to run your job.
Once the job is complete, you should see your Cypress test results published in Jenkins. You can then configure your pipeline to trigger on code changes, schedule builds, and more.
That's it! You've successfully connected your Cypress tests to a DevOps CI/CD pipeline using Jenkins.
--
@@RaghavPal Thanks Raghav, First ime implementing automation using cypress by following your videos. You're doing awsome work you're a genius.
Hi RaghavPal, i love yout videos, i can't find BDD for cypress. please can you help with that
Ayanloye
Have not created specific to BDD. can check all lectures here - automationstepbystep.com/
Any cypress examples videos?
Hi, Can check all cypress videos here - automationstepbystep.com/
I think you have missed to add masterclass 3 for cypress. Can you please add that video or if it is already added can you please provide the link.
Thanks in advance 👍
Hi Rakesh, yes, it was missed, will publish it today
Hi Raghav, When are you going to make the next tutorial video. I'm impatiently waiting for the next Cypress API tutorial 😀.
As soon as possible
I am looking for a good lesson on using custom commands and cy.session for login any recommendations?
Sure, here are some resources for learning how to use custom commands and cy.session in Cypress:
Cypress Custom Commands: This is the official documentation for creating and using custom commands in Cypress. It includes examples and explanations of how to create custom commands, as well as best practices for using them effectively. You can find it here: docs.cypress.io/api/cypress-api/custom-commands
Cypress Session: This is the official documentation for using cy.session in Cypress. It explains how to use cy.session for logging in and maintaining state across tests. You can find it here: docs.cypress.io/api/commands/session
Cypress Recipes: This is a collection of useful code snippets and tips for working with Cypress, including custom commands and cy.session. You can find it here: github.com/cypress-io/cypress-example-recipes
I hope these resources help you learn more about using custom commands and cy.session in Cypress!
Hi Raghav,
Can we have one videos for running Cypress file from Jenkins CICD Pipeline using Github
I will plan Rakesh
Thank you
You're welcome
Hi Raghav, I need your guidance. I wrote a script in Cypress to find duplicate entries in PDFs. It works when I have one file in fixtures. Now, I want to take it a step further. I want to create a folder, put all my PDF files there, and dynamically read them using their file extensions or other annotations. Then, I want to log the findings in a report with the corresponding file names so that the user can easily see which file has duplicate entries. Can you help me with this?
Noor
Here are the steps on how to create a Cypress script to find duplicate entries in PDFs and log the findings in a report with the corresponding file names:
1. Create a folder to store your PDF files.
2. Put all your PDF files in the folder.
3. Create a new Cypress script file.
4. Import the following modules:
```javascript
import fs from 'fs';
import pdfjsLib from 'pdfjs-dist';
```
5. Define a function to read a PDF file:
```javascript
function readPDF(filePath) {
return new Promise((resolve, reject) => {
fs.readFile(filePath, (err, buffer) => {
if (err) {
reject(err);
return;
}
const pdfDoc = pdfjsLib.getDocument(buffer);
pdfDoc.promise.then(resolve);
});
});
}
```
6. Define a function to find duplicate entries in a PDF file:
```javascript
function findDuplicateEntries(pdfDoc) {
const pages = pdfDoc._pdfInfo.numPages;
const entries = [];
for (let i = 1; i textContent.items.map(item => item.str).join(' '));
entries.push(text);
}
const uniqueEntries = new Set(entries);
const duplicateEntries = entries.filter(entry => !uniqueEntries.has(entry));
return duplicateEntries;
}
```
7. Define a function to log the findings in a report:
```javascript
function logFindings(duplicateEntries, fileName) {
const reportFile = fs.createWriteStream('report.txt');
reportFile.write(`File name: ${fileName}
`);
duplicateEntries.forEach(entry => {
reportFile.write(`Duplicate entry: ${entry}
`);
});
reportFile.end();
}
```
8. Write the main test case:
```javascript
it('should find duplicate entries in PDFs', async () => {
const pdfFiles = fs.readdirSync('./pdfs');
for (const pdfFile of pdfFiles) {
const filePath = `./pdfs/${pdfFile}`;
const pdfDoc = await readPDF(filePath);
const duplicateEntries = await findDuplicateEntries(pdfDoc);
if (duplicateEntries.length > 0) {
logFindings(duplicateEntries, pdfFile);
}
}
});
```
9. Run the Cypress script:
```
npx cypress run
```
This will generate a report.txt file with the list of duplicate entries for each PDF file.
I hope this helps
@@RaghavPal Thankyou raghav , it was too detailed and understandable.
Sir can you put a video for...how to read data from Excel file using Cypress
I will add Annie
@@RaghavPal Sir I have one doubt...in Cypress using mochawesome report...if I am running a test case...each time when I run..it will generate the report ah?....or only if I gave the comment for generate report in the command prompt terminal it will generate report ah? And also if I'm generation a report for a test case at time 11 ....and once again at 12...it will give separate report or it will overwrite it?
Dear Raghav, I was wondering where is link for masterclass 3 for Cypress? Did you miss it? or this masterclass is number 3 insted of 4?
yes, it was missed, will publish it today
Hi sir please add masterclas 3 for cypress, please upload that
Hi Ahtisham, yes, it was missed, will publish it today
What is the difference between the masterclass courses, is it down to versions?
Hi, Masterclass sessions are complete projects/frameworks in single session or at most 3-4 parts
@@RaghavPal So to learn about the basics, which course/list of videos should we use?
Both can work, in case of Cypress, masterclass will be good as it was created with the newer version
@@RaghavPal so i ll watch one of the latest masterclass videos and apply them straight? Will it be enough for the basics?
Yes, more than basics, you can do any Cypress project after this
Hello, I have a question. In Cypress, when the test comes to an end, the chrome window (and other bowsers if used) closes and returns to the main page, where we have Specs, Runs, Settings etc. How to keep it in the chrome window?
Hi SineQuaNon,
In Cypress, you can use the cy.end() command to end a test and keep the browser window open. This command ends the currently running test but keeps the browser window open, allowing you to interact with the application manually or run further tests.
For example:
describe('My test', () => {
it('does something', () => {
// ... test code here
cy.end() // end the test but keep the browser window open
})
})
Alternatively, you can use the cy.debug() command to pause the test and open the browser's developer tools. This allows you to interact with the application and debug any issues.
describe('My test', () => {
it('does something', () => {
// ... test code here
cy.debug() // pause the test and open the browser's developer tools
})
})
cy.end() and cy.debug() can only be used within a test and not in before or after hooks.
@@RaghavPal Many thanks Raghav. I really appreciate you taking the time and providing such a detailed answer. Regards,
sir when will you post the 5th video? , I want cucumber with cypress !!
I will plan on it
what to do, if input type =button, not file, how to browse for that
Hi, you can use the cy.get() command to select the file input element, and then use the cy.attachFile() command to upload a file. Here is an example:
/*
cy.get('input[type=button]').attachFile('path/to/file.txt')
*/
Make sure the element is visible and active (not hidden)
Hi Raghav I followed your instructions for downloading file, but I am getting this error: Object prototype may only be an object or null
Hi Azima, not too sure on this, This can be app side issue,
this can help - stackoverflow.com/questions/57421582/typeerror-object-prototype-may-only-be-an-object-or-null-undefined-angular-8
Why bdd is removed from this section ?
I will check and add lecture on that Reshma
Can u make a video on cy.session as i am new not able to follow it ,like i have test 1,2,3,4 under test scenario when i execute test case 1,2 executes but user automatically loges out on test 3,4 i am stuck here ,it would be great if you could help me with some example
I will do Gurinder
@@RaghavPal thank you ..
kindly share a link..in version 10 i am also faced same situation.
where can I get master class 5
I'm done with these four and Learnt a lot Thanks for such a useful videos ...But unable to get further master sessions
Hi Revti, as of now there are 4 sessions. Can check the playlists here - automationstepbystep.com/
cypress reporting is not explained in this video ???
Can check cypress playlist here - automationstepbystep.com/
Hi Raghav! Thank you for your tutorials.
I followed Masterclass 1-4 here. Then I went to the following video for HTML reports, where you used cypress.json file to add configuration.
th-cam.com/video/J9AHVKNDkDU/w-d-xo.htmlfeature=shared
But in my project I do not have cypress.json file. Could you tell me how I can get this file to add configuration please?
Wayez
The cypress.json file is no longer needed in the latest version of Cypress.
This will help:
Using a cypress.json configuration file is no longer supported. Replace this configuration file with a cypress.config.js, cypress.config.ts, cypress.config.cjs or cypress.config.mjs file.
docs.cypress.io/guides/references/changelog
docs.cypress.io/guides/references/configuration
Hi Raghav , I followed your all 4 tuturial sessions. Thank you for all your great videos 😃.
I have done them with TypeScript. Only last one with File download I get 2 error messages. One " Try `npm i --save-dev @types/cypress-downloadfile` if it exists or add a new declaration (.d.ts) file containing `declare module 'cypress-downloadfile/lib/addPlugin';`ts(7016).
P.S. I would like also to mention that my addPlugin in js extend type. Should I change/download addPlugin in ts extend type? How can I do that? I could not achieve that.
The other error message. I have "require" red underlined "require('cypress-downloadfile/lib/downloadFileCommand')" when I write this in commond.ts file.
Cannot find name 'require'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node` and then add 'node' to the types field in your tsconfig.
I downloaded this npm i --save-dev @types/node. But it doesn't help me.
I could not solve this issue all day. Could you pls. help me?
Hi, I will need to check this with hands-on, for now can try some online help
hey Raghav. it seems .attachFile ( ) function has been deprecated. I keep getting the "cy.get(...).attachFile is not a function error. ANy alternative?
EDIT: I used .selectFile and it seems to work.
Great
cy.preserveOnce is not working for me.. If there is an alternative to cypress.cookies.preserveOnce in version 10 please share a link. If there is no video, please make one. Thank you very much.
Hi Habib, I will need to check, see if this helps - stackoverflow.com/questions/69605268/cypress-cookies-preserveoncesession-id-isnt-working-when-called-in-aftereac
Thank You
You're welcome