Skip to content

Instantly share code, notes, and snippets.

View amitasehrawat's full-sized avatar

amitasehrawat

View GitHub Profile
@amitasehrawat
amitasehrawat / cypress-RegularExpression-Examples.js
Created June 9, 2023 09:18
Cypress- Common Regular Expression Examples
// test.spec.js
describe('Regular Expressions in Cypress', () => {
it('should demonstrate the usage of regular expressions', () => {
// Example 1: Validating an email address using regex
cy.get('#email-input').type('example@test.com');
cy.get('#email-input').should('match', /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/);
// Example 2: Verifying the presence of a phone number using regex for format "Phone: +XXX-XXX-XXX-XXXX", where X represents a digit
cy.contains(/^Phone:\s+\+\d{1,3}-\d{3}-\d{3}-\d{4}$/);
@amitasehrawat
amitasehrawat / Cypress-AssertChildElementsIncludeProvidedString.js
Created June 7, 2023 14:16
Cypress: How to verify if all child element contains a expected text str
// type definitions for Cypress object "cy"
/// <reference types="cypress" />
describe('My First Cypress Test', function() {
it('verifies that each child element of myElement contains the expected text str.', () => {
const myElement = cy.get('#my-element');
let str = TextToValidate;
myElement.its('length')
.then(count => {
cy.log('count='+count);
@amitasehrawat
amitasehrawat / Java_CreateExcel
Created September 10, 2019 05:17
java_CreateExcel
import java.io.File;
import java.io.FileOutputStream;
import org.apache.poi.xssf.usermodel.XSSFCell;
import org.apache.poi.xssf.usermodel.XSSFRow;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
public class excel_Functions1 {