npm install cypress --save-dev
npx cypress open
npx cypress run
npx cypress run --headed
npx cypress run --browser chrome
npx cypress run --browser chrome --record
npx cypress run --browser chrome --record --key 12345678-1234-1234-1234-123456789012
npx cypress open
npx cypress open --spec "cypress/integration/mytest.spec.js"
npx cypress run --spec "cypress/integration/mytest.spec.js"
cy.visit("http://localhost:3000"); // whatever the URL is
cy.title();
cy.url();
describe("My First Test", () => {
it("verify title-positive", () => {
// lunch the app
cy.visit("http://localhost:3000/");
// check the title
cy.title().should("eq", "Pitchspot");
});
it("verify title-negative", () => {
// lunch the app
cy.visit("http://localhost:3000/");
// check the title
cy.title().should("eq", "Pitchspot1");
});
});
cy.get("#id");
cy.get(".class");
cy.get("tag");
cy.get("[attribute]");
cy.get("[attribute='value']");
cy.get("[attribute*='value']");
cy.get("[attribute$='value']");
cy.get("[attribute^='value']");
cy.get("[attribute*='value']");
cy.get("button").click();
cy.get("input").type("Faruk");
cy.get("input").clear();
cy.get("select").select("Faruk");
cy.get("input").check();
cy.get("input").uncheck();
cy.title().should("eq", "Pitchspot");
cy.url().should("include", "http://localhost:3000");
cy.get("button").should("be.visible");
cy.get("button").should("not.be.visible");
cy.get("button").should("be.enabled");
cy.get("button").should("be.disabled");
cy.get("input").should("be.checked");
cy.get("input").should("not.be.checked");
cy.get("select").should("be.selected");
describe("Login Test", () => {
it("Login with valid credentials", () => {
cy.visit("http://localhost:3000/login");
cy.get('input[name="email"]').type("sfaruk1137@gmail.com");
cy.get('input[name="password"]').type("Faruk123@");
cy.get('button[type="submit"]').click();
cy.url().should("include", "http://localhost:3000/dashboard");
});
});
describe("Logout Test", () => {
it("Logout", () => {
// remove the cookie
cy.clearCookie("token");
});
});
describe("My First Test", () => {
before(() => {
// runs once before all tests in the block
});
after(() => {
// runs once after all tests in the block
});
beforeEach(() => {
// runs before each test in the block
});
afterEach(() => {
// runs after each test in the block
});
it("verify title-positive", () => {
// lunch the app
cy.visit("http://localhost:3000/");
// check the title
cy.title().should("eq", "Pitchspot");
});
it("verify title-negative", () => {
// lunch the app
cy.visit("http://localhost:3000/");
// check the title
cy.title().should("eq", "Pitchspot1");
});
});
describe("My First Test", () => {
it("verify title-positive", () => {
// lunch the app
cy.visit("http://localhost:3000/");
// check the title
cy.title().should("eq", "Pitchspot");
cy.title().should("include", "Pitch");
cy.title().should("not.eq", "Pitchspot1");
cy.title().should("not.include", "Pitch1");
});
it("verify title-positive", () => {
// lunch the app
cy.visit("http://localhost:3000/");
// check the title
expect(cy.title()).to.eq("Pitchspot");
expect(cy.title()).to.include("Pitch");
expect(cy.title()).to.not.eq("Pitchspot1");
expect(cy.title()).to.not.include("Pitch1");
});
});
describe("My First Test", () => {
it("verify title-positive", () => {
// lunch the app
cy.visit("http://localhost:3000/");
// check the title
cy.title().should("eq", "Pitchspot");
cy.title().should("include", "Pitch");
cy.title().should("not.eq", "Pitchspot1");
cy.title().should("not.include", "Pitch1");
});
});
describe("My First Test", () => {
it("verify title-positive", () => {
// lunch the app
cy.visit("http://localhost:3000/");
// check the title
cy.get("button").should("have.class", "btn");
cy.get("button").should("not.have.class", "btn1");
});
});
describe("My First Test", () => {
it("verify title-positive", () => {
// lunch the app
cy.visit("http://localhost:3000/");
// check the title
cy.get("button").should("have.id", "btn");
cy.get("button").should("not.have.id", "btn1");
});
});
describe("My First Test", () => {
it("verify title-positive", () => {
// lunch the app
cy.visit("http://localhost:3000/");
// check the title
cy.get("button").should("have.attr", "type", "submit");
cy.get("button").should("not.have.attr", "type", "button");
});
});
describe("My First Test", () => {
it("verify title-positive", () => {
// lunch the app
cy.visit("http://localhost:3000/");
// check the title
cy.get("button").should("have.value", "Submit");
cy.get("button").should("not.have.value", "Submit1");
});
});
describe("My First Test", () => {
it("verify title-positive", () => {
// lunch the app
cy.visit("http://localhost:3000/");
// check the title
cy.get("button").should("have.text", "Submit");
cy.get("button").should("not.have.text", "Submit1");
});
});
describe("My First Test", () => {
it("verify title-positive", () => {
// lunch the app
cy.visit("http://localhost:3000/");
// check the title
cy.get("button").should("have.css", "background-color", "rgb(0, 0, 255)");
cy.get("button").should("not.have.css", "background-color", "rgb(0, 0, 0)");
});
});
{
"baseUrl": "http://localhost:3000"
}
describe("My First Test", () => {
it("verify title-positive", () => {
// lunch the app
cy.visit(Cypress.env("baseUrl"));
// check the title
cy.title().should("eq", "Pitchspot");
});
});
describe("My First Test", () => {
it("verify title-positive", () => {
// lunch the app
cy.visit(Cypress.env("baseUrl"));
// check the title
cy.title().should("eq", "Pitchspot");
cy.get("button").click();
cy.get("button").dblclick();
cy.get("button").rightclick();
cy.get("button").trigger("mouseover");
cy.get("button").trigger("mouseout");
cy.get("button").trigger("mousedown");
cy.get("button").trigger("mouseup");
cy.get("button").trigger("mousemove");
cy.get("button").trigger("mouseenter");
cy.get("button").trigger("mouseleave");
cy.get("button").trigger("keydown");
cy.get("button").trigger("keyup");
cy.get("button").trigger("keypress");
cy.get("button").trigger("focus");
cy.get("button").trigger("blur");
cy.get("button").trigger("change");
cy.get("button").trigger("submit");
cy.get("button").trigger("scroll");
cy.get("button").trigger("select");
cy.get("button").trigger("drag");
cy.get("button").trigger("dragend");
cy.get("button").trigger("dragenter");
cy.get("button").trigger("dragleave");
cy.get("button").trigger("dragover");
cy.get("button").trigger("dragstart");
cy.get("button").trigger("drop");
cy.get("button").trigger("copy");
cy.get("button").trigger("cut");
cy.get("button").trigger("paste");
cy.get("button").trigger("input");
cy.get("button").trigger("invalid");
cy.get("button").trigger("reset");
cy.get("button").trigger("search");
cy.get("button").trigger("select");
cy.get("button").trigger("touchcancel");
cy.get("button").trigger("touchend");
cy.get("button").trigger("touchmove");
cy.get("button").trigger("touchstart");
cy.get("button").trigger("wheel");
});
});
describe("My First Test", () => {
it("verify title-positive", () => {
// lunch the app
cy.visit(Cypress.env("baseUrl"));
// check the title
cy.title().should("eq", "Pitchspot");
cy.get("input").type("Hello");
cy.get("input").type("{enter}");
});
});
describe("My First Test", () => {
it("verify title-positive", () => {
// lunch the app
cy.visit(Cypress.env("baseUrl"));
// check the title
cy.title().should("eq", "Pitchspot");
cy.get("input").type("Hello");
cy.get("input").type("{enter}");
cy.get("input").type("World");
});
});
it("Click Multiple Elements under Class or Data-Test", () => {
cy.get('div[dataTest="publishToServicesChecks"]')
.find("span")
.each(($el) => {
cy.wrap($el).click({
force: true,
multiple: true,
});
});
});