Reusable commands in Cypress || Write Generic Functions - Part - 14
Vložit
- čas přidán 15. 07. 2024
- In this video, I have explained how to create generic functions and commands in Cypress and how to use them in your test spec.
Cypress provides a feature to write your generic functions in commands.js file which will be loaded first before your tests and the same function can be called in your test by Cypress.
Git Repo for all Cypress Examples:
github.com/naveenanimation20/...
~~~Subscribe to this channel, and press bell icon to get some interesting videos on Selenium and Automation:
czcams.com/users/Naveen%20Au...
Follow me on my Facebook Page:
/ naveenqtpexpert
Let's join our Automation community for some amazing knowledge sharing and group discussion on Telegram:
t.me/joinchat/COJqZUPB02r5sB7...
Paid courses (Recorded) videos:
naveenautomationlabs.com/reco...
For Java & Selenium - naveenautomationlabs.com/selen...
For API (Manual + Automation) - naveenautomationlabs.com/manua... - Věda a technologie
Once again Naveen, Brilliant! Well explained, to the point and always daily common used examples. Can't wait for the next upload, keep up the awesome work!!!!!
Thanks @Naveen AutomationLabs. We could gain much knowledge on Cypress and related topics. Could you please make more videos on Cypress API and also on Framework part
Thanks Bro !!! big help
Thanks!
Hello Naveen, when do you start the API class? I'd like to sign up.
Should we use custom commands instead of POM?
very helpful session. I am facing issue (test runner is closing immediatly), pls let me know how not to exit from test runner
Hey Naveen, How to check if has ?
ul > li
**I am Trying to draw rectangular shape on canvas in Cypress Automation, but it is not allowing to do so. All we need to click and hold from one diagonal point and drag& drop let's say from (1,1) to another coordinate point(2,2). Then our task would be done.
Note: But the problem here is the source element point (1,1) is not any element it's just a point on canvas and if we hold this value in ILocation interface then we cannot use any drag and drop plugin because in drag arguments the source & target parameter should be element string.
Have used the below trigger code also but this also did not work for me.
export function drawRectangle(start: ILocation, size: number): any {
//'start' is the mid point of coordinate
// size is 100
const source = {x: start.x, y: start.y}
const dest= {x: start.x + size, y: start.y + size }
cy.get('.div.canvas-container').click(source.x, source.y).as('sourcePoint');
cy.get('@sourcePoint'). trigger ("mousedown", {force:true})
cy.get('.div.canvas-container').trigger ("mousemove", {source, dest}, {force:true})
cy.get('.div.canvas-container').click(dest.x, dest.y).as('destPoint');
cy.get('@destPoint'). trigger ("mouseup", {force:true})
}
Do we need to import the cypress in command.js file like below:
import cypress from "cypress"
because I am getting error : The following error originated from your test code, not from Cypress.
> cypress is not defined.
If I use the import function then I am getting errors too in node_modules folder,
If I remove this command the code is running without any issue
what should I do to resolve it, either way, I am getting errors if I use import or without import call.
please help
I see that after execution of 1st it block, it automatically signout from the page. 2nd and 3rd it block, again sign in button is displayed.
Hi is it possible in cypress to run
1. Specs file in parallel
2. It block in parallel
Hi Naveen, instead of hard coded values of email and password, can we read them from some config.properties file or some excel file?
That will be covered later.
U can use fixtures
@Naveen Bhaiya, As i seen in your video that we dont need to login again & again for every 'it' block so you have used before function but sir cypress has removed this function in version above 12, how we can achieved this feature ? please reply bhaiya.
@Naveen, I am also looking this info.
Instead of logging in again and again I want to login only once then other tests should continue. Though I put Login code in before(), my test is not continuing .
Hello Naveen. i stuck one scenario.. i want to run 2000k scripts parrallel execution for nightly build.
one script takes around average 3 mins.. can you pleas guid me how to handle this kind issues
Available resources:- selenium, java, testing, maven, jenkins, git
OR anybody can help me if possible
Sir I need to practice in eclipse.it's possible or not
You can but please use visual studio code for Java script based tools
You can but please use visual studio code for Java script based tools
@@naveenautomationlabs tq sir for your information
I learn selenium from your CZcams chaneel.I get soo much information from your classes sir