4.11.22

Cypress Cucumber Setup

 


Install the plugin by running:

$ npm install --save-dev cypress-cucumber-preprocessor


Running Cucumber feature file with TAGS like @Smoke & @Regression:

$ npx cypress-tags run -e TAGS="@Smoke" --headed --browser chrome

26.10.22

Cypress.io Imp CMD's

$ npm -i init :  to create package.json file

$ node_modules/.bin/cypress open :  to open the test runner

Cypress run commands:- can use either of the below 4 commands

$(npm bin)/cypress run
./node_modules/.bin/cypress run
npx cypress run
yarn cypress run


Cypress run commands for 1 test case:-

$ npm run cy:run -- --record -- spec "cypress/integration/myspec.js" 

by default all test cases from cmd line runs in headless mode. if needed to run in browser? need to mention --headed in the end of cmd.

./node_modules/.bin/cypress run --headed                                    $ npm -i init :  to create package.json file

if we need to run spec's in specific browser we can specify that in cmd.

$ ./node_module/.bin/cypress run --browser chrome

$ ./node_module/.bin/cypress run --browser edge


Cypress framework folder structure:

fixture: for storing data in json or excel files.

Integration: for writing test spec's

Plugins: for setting browser settings like full screen, to handel cypress listeners events.

Support: customize cmds,  reusable methods, basically used to build POM

Videos: it stores the latest execution proofs of test specs


CMD to install mocha:-

$ npm install --save-dev mocha

CMD to install mochawesome reports:-

$ npm install --save-dev mochawesome


CMD to install IFrame in Cypress:

npm install -D cypress-iframe

CMD to override the execution url from terminal:-

$ ./node_module/.bin/cypress run --spec cypress/integration/UI/TestFramework1.js --env url=https://rahulshettyacademy.com/angularpractice/shop --headed

CMD to run scripts and have results in dashboard:-

npx cypress run --record --key <"your respective project key from dashboard">


22.9.22

Jenkins

Connect VM machine

Connect through SSH

 Jenkins installation:-

$> sudo apt-get update.

$> sudo apt install openjdk-8-jdk (OR) sudo apt install default-jdk

$> wget -q -O - https://pkg.jenkins.io/debian-stable/jenkins.io.key |  sudo apt-key add -

wget --no-check-certificate -qO - http://pkg.jenkins-ci.org/debian/jenkins-ci.org.key | sudo apt-key add -

$> sudo sh -c 'echo deb https://pkg.jenkins.io/debian-stable binary/ > \
/etc/apt/sources.list.d/jenkins.list'
$> sudo apt-get update
$> sudo apt-get install jenkins




sudo su - ubuntu

sudo apt-get update


20.9.22

GIT commands

 Working Directory:-

  • Project folder resides in your system.
  • It may or may not be tracked by Git.
  • Git tracking is initiated by "git init", it automatically creates a hidden .git folder.

Staging Area:-

  • Once you are in working directory , we have to specify which files are to be/not tracked by mentioning in the gitignore.
  • Some of the temp files need to be ignored which don't need to be tracking.
  • To add files into staging area, we "git add".

Commit:-   

  • Once files are moved into staging , we can commit them to repo, until it's not commited to git its not saved in repo.
  • "git commit -m "code change message".
  • Commit id will be generated once you commit any thing, to manage versioning.


Github:-

  • Once code is committed to your local repo, we need to publish it to remote server.
  • "git push"
  • commit id will help in revert the code to previous version.
  • A pointer to latest commit is called HEAD.


Master branch & Feature Branch.



git setup in GCP, Ubuntu instance:-

  • check if git is already exists?  git --version.
  • "mkdir  git_demo" : create a folder for repo.
  • ls -ltr and ls -ltra(hidden files)
  • run "git init" to track changes in this folder
  • "ls -ltra"
  • "ls -ltr .git"
  • "cat .git/HEAD" will show the head pointer.
  • "git status" to track/see the changes in repo.
  • "git add ."  this add all the files in the current directory to tracking, "." mean current directory files, no hidden files will be added for tracking.
  • "git rm --cached <file>..." to unstage/remove files.
  • "git config --global user.email xyz@gmail.com"
  • "git_demo$ git config --global user.name xyz"
  • "git remote add origin https://github.com/xyz/GitRemoteRepoTest.git"
  • "git push"
  • "git push origin master". enter username"xyz" and personal access token.
  • Refer:- https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token

Cloning a Repo:- 
  • Go to github and copy the url for clone "https://github.com/xyz/GitRemoteRepoTest.git"
  • "git clone https://github.com/xyz/GitRemoteRepoTest.git" run this command in new folder for creating the git repo.
  • git pull https://github.com/xyz/GitRemoteRepoTest.git ( to pull updated changes from repo).
GIT Branching:-

  • "Git branch <anybranch name>".      to create new branch
  • git branch.                                          to list the branches
  • git checkout <newbranch name>.    this will make HEAD point to new branch.
  • git log --graph --pretty=oneline
GIT STASH:-

git stash -u
git stash pop

GIT REVERT:-

git revert <commit id>

GIT DIFF:- To find difference between two versions of the file.

git diff <commit id>


MERGING BRANCHES:-

Git Merge:

git merge <source branch name/feature branch name>    run this cmd from the master branch.

Git Rebase:

It's more used to get the latest master branch code to feature branch, once after the feature branch code is tested and merged into master branch.  it helps the feature branch to rebase the latest code from master.

1. "git checkout <featurebranch name>"      2. "git rebase master"






19.9.22

Useful Cypress commands

 

1. To Run Single test :

npx cypress open --config testFiles="/Users/rajeshvarma/Documents/CypressProj/cypress/integration/UIScripts/tc1.spec.js"    ---------------------------------------------------------------------------------------------------------------------------  

2. To run cypress multiple test cases option:

npx cypress open

---------------------------------------------------------------------------------------------------------------------------

3. crossbrowser testing:-

$ npx cypress run --browser chrome --spec “cypress/integration/examples/tests/e2e_test.spec.js”

update package.json file with below entries for crossbrowser:

"scripts": {
"cy:run:chrome": "cypress run --browser chrome",
"cy:run:firefox": "cypress run --browser firefox"

}

---------------------------------------------------------------------------------------------------------------------------

4. Cypress reporting:-

$ npm install mochawesome.   OR.      $ npm install junit

 update cypress.json file with below entries :-

{
"reporter": "mochawesome",
"reporterOptions":
{
"reportDir": "cypress/results",
"overwrite": false,
"html": true,
"json": true
}

}



$ npx cypress run --reporter mochawesome --spec “cypress/integration/examples/tests/e2e_test.spec.js”



Cypress.json config file for JUnit:--

{
"reporter": "junit",
"reporterOptions":
{
"reportDir": "cypress/results",
"mochaFile": "results/my-test-output.xml",
"toConsole": true
}

}


$ npx cypress run --reporter junit \ --reporter-options “mochaFile=results/my-test-output.xml,toConsole=true”

---------------------------------------------------------------------------------------------------------------------------