Skip to main content

The High Demand for Programming Languages: Exploring Java and Python

 πŸ’₯The High Demand for Programming Languages: Exploring Java and Python πŸ’»πŸ‘€πŸ’ͺ Introduction: In today's world, having knowledge and skills in programming languages can open up a plethora of job opportunities in both small and large companies. Programming languages are essential for computer literacy and education, and their popularity continues to grow. While the demand for certain programming languages may change, the need for skills and knowledge has not decreased.  πŸ’₯πŸ“—πŸ’‘The Power of Java: Java is a versatile programming language and platform that has become highly popular. It has enormous potential as a programming language, and if you already know other programming languages, Java is directly related. Its versatility makes it an attractive choice for companies of all sizes, and its usefulness has made it one of the most in-demand programming languages today. πŸ’ͺπŸ˜ŽπŸ’­Python - A Game Changer: Python is another programming language that is always a topic of discussion. Its us...

Cypress Notes

Cypress Notes



Install Cypress

npm install cypress --save-dev

Run Cypress

npx cypress open

Run Cypress in headless mode

npx cypress run

Run Cypress headed mode

npx cypress run --headed

Run Cypress in headless mode with a specific browser

npx cypress run --browser chrome

Run Cypress in headless mode with a specific browser and record the test

npx cypress run --browser chrome --record

Run Cypress in headless mode with a specific browser and record the test with a specific key

npx cypress run --browser chrome --record --key 12345678-1234-1234-1234-123456789012

Cypress test

Create a test

npx cypress open

Create a test with a specific name

npx cypress open --spec "cypress/integration/mytest.spec.js"

Create a test with a specific name and run it

npx cypress run --spec "cypress/integration/mytest.spec.js"

Cypress Functions

To launch application

cy.visit("http://localhost:3000"); // whatever the URL is

To get the title of the page

cy.title();

To get the URL of the page

cy.url();

Here is a Example

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");
  });
});

Locators

To get the element by ID

cy.get("#id");

To get the element by class

cy.get(".class");

To get the element by tag

cy.get("tag");

To get the element by attribute

cy.get("[attribute]");

To get the element by attribute and value

cy.get("[attribute='value']");

To get the element by attribute and value with wildcard

cy.get("[attribute*='value']");

To get the element by attribute and value with wildcard at the end

cy.get("[attribute$='value']");

To get the element by attribute and value with wildcard at the beginning

cy.get("[attribute^='value']");

To get the element by attribute and value with wildcard at the beginning and end

cy.get("[attribute*='value']");

Actions

To click on the element

cy.get("button").click();

To type in the element

cy.get("input").type("Faruk");

To clear the element

cy.get("input").clear();

To select the element

cy.get("select").select("Faruk");

To check the element

cy.get("input").check();

To uncheck the element

cy.get("input").uncheck();

Assertions

To check the title of the page

cy.title().should("eq", "Pitchspot");

To check the URL of the page

cy.url().should("include", "http://localhost:3000");

To check the element is visible

cy.get("button").should("be.visible");

To check the element is not visible

cy.get("button").should("not.be.visible");

To check the element is enabled

cy.get("button").should("be.enabled");

To check the element is disabled

cy.get("button").should("be.disabled");

To check the element is checked

cy.get("input").should("be.checked");

To check the element is not checked

cy.get("input").should("not.be.checked");

To check the element is selected

cy.get("select").should("be.selected");

Code Snippets

To login

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");
  });
});

To logout

describe("Logout Test", () => {
  it("Logout", () => {
    // remove the cookie
    cy.clearCookie("token");
  });
});

Before and After

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");
  });
});

Should vs Expect

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");
  });
});

Should all Methods

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");
  });
});

Class prasent or not

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");
  });
});

ID prasent or not

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");
  });
});

Attribute prasent or not

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");
  });
});

Value prasent or not

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");
  });
});

Text prasent or not

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");
  });
});

To check color of the element

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)");
  });
});

Add Environment Variables

First we have to create a file called cypress.env.json

{
  "baseUrl": "http://localhost:3000"
}

Then we can use it in our test

describe("My First Test", () => {
  it("verify title-positive", () => {
    // lunch the app
    cy.visit(Cypress.env("baseUrl"));
    // check the title
    cy.title().should("eq", "Pitchspot");
  });
});

Mouse and Keyboard Events

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");
  });
});

Enter key

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}");
  });
});

Enter Key and type some text

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");
  });
});

Click Multiple Elements under Class or Data-Test

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,
      });
    });
});

Comments

bottom ads

Popular Posts

React Js Interview Questions and AnswersπŸ’₯πŸ’₯

πŸ’₯ React Interview Questions and Answer πŸ’₯ 1. What is React?      Answer: React is a JavaScript library for building user interfaces. It was developed by Facebook and has become one of the most popular libraries for front-end web development. 2. What is JSX?      Answer: JSX is a syntax extension for JavaScript that allows you to write HTML-like code in your JavaScript files. It is used in React to define the structure and layout of components. 3. What is a component in React?      Answer: A component is a reusable piece of code that defines the structure and behavior of a part of a user interface. Components can be nested within each other to create complex interfaces. 4. What is the difference between props and states in React?      Answer: Props are used to pass data from a parent component to a child component, while the state is used to manage data within a component. Props are read-only, while the state can be modified us...

CSS New Units πŸ’₯: A Beginner's Guide by Code Crushers 😍😍😍😍

❤CSS New Units πŸ’₯: A Beginner's & New Units 😍 Guide by Code CrushersπŸ’£     Click here to Watch a Video to better understand  πŸ“‚      CSS units are an essential part of web design. They allow you to define the size and position of elements on a webpage. Understanding the different types of CSS units is crucial to creating responsive and visually appealing websites. In this blog post, we'll take a look at the different types of CSS units and provide examples of how they can be used. Absolute Units:- Absolute units have a fixed size and do not change based on screen size or device. These units are useful for defining precise sizes for elements, such as font sizes or border widths. Pixels (px) Pixels are the most commonly used absolute unit in CSS. One pixel is equal to one dot on a screen, regardless of its density. For example, to set the font size of an element to 16 pixels, you would write: font-size : 16px ;  Points (pt) Points are another absolu...

React vs Angular vs Vue

# React vs Angular vs Vue ## React ### History of React - React was created by Jordan Walke, a software engineer at Facebook, who released an early prototype of React called "FaxJS". - He was influenced by XHP, an HTML component framework for PHP. - It was first deployed on Facebook's News Feed in 2011 and later on Instagram.com in 2012. - It was open-sourced at JSConf US in May 2013. ### What is React? - React is a JavaScript library for building user interfaces. - React is used to build single-page applications. - React allows us to create reusable UI components. - React was first created by Jordan Walke, a software engineer working for Facebook. - React was first deployed on Facebook's News Feed in 2011 and on Instagram.com in 2012. ### Why React? - React is a declarative, efficient, and flexible JavaScript library for building user interfaces. - It lets you compose complex UIs from small and isolated pieces of code called "components". ### React Features...