Friday, October 4, 2019

Cypress - Automation tool

Cypress.io - Automation tool
------------------------------------

How to install cypress: https://docs.cypress.io/guides/getting-started/installing-cypress.html
---------------------------------------------------------------------------------------------------------------
1. install Homebrew (if not already installed)
- ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

2. install node:
- brew install node
- brew upgrade node
- check node -v

2. install npm:
- npm is the world's largest Software Library (Registry)
- npm is also a software Package Manager and Installer)
- check if npm is already installed by checking npm -v
- if not, type install npm
- check npm -v

3. install cypress:
- npm install cypress --save-dev

4. install supporting libraries:
- npm install --save-dev @testing-library/dom
- npm install --save-dev @testing-library/react
- npm install --save-dev @testing-library/jest-dom
- npm install --save-dev cypress @testing-library/cypress
- npm install -g eslint
- npm install -g node-modules

More info here:
1. https://github.com/cypress-io/cypress
2. https://docs.cypress.io/guides/getting-started/installing-cypress.html

Cypress FAQ:
-----------------
1. how to open cypress(once installed)
./node_modules/.bin/cypress open
or, npx cypress open (prefer)
or, yarn run cypress open

2. how to create a file
- open terminal and create a file e.g. test1.js inside folder: /Users/rakesh/cypress/integration

3. how to run the above file using cypress - test runner
- in the testrunner, under integration , look for above file(test1.js) and click on it
- it will launch in chrome (url: http://localhost:51636/__/#/tests/integration/test1.js) and
shows the result

4. how to run cypress in headless mode:
https://snipcart.com/blog/frontend-testing-cypress

$ cypress run

5. how to run a js code locally in the terminal:
node file.js

Cypress Pros and Cons:
-----------------------------

Pros:
1. its built for front end/automation developers
2. it uses JS language, which front end webpages are also written in
3. it uses Mocha testing framework

Cons:
1. Cypress does not support cross browser testing:
- latest update: https://github.com/cypress-io/cypress/issues/310
2. Cypress supports only JS

Cypress Best practises:
-----------------------------
1. how to select elements properly:
https://docs.cypress.io/guides/references/best-practices.html#Selecting-Elements

2. assertions:
https://docs.cypress.io/guides/references/assertions.html#Chai

Monday, June 16, 2014

API Testing

Q&As
-------------
What is an API?
Application Programming Interface. It is an interface to make HTTP calls with REST or SOAP methods. Both methods can use JSON or XML as their input.

What involves API testing?
API Testing involves testing the response after making a API request. The request and response can be either support JSON or XML format.
It is different than GUI testing in the sense that you test for business logic here rather than concentrating on look and feel of the application.

What tools to be used for API testing?

For API testing, there are several free tools:
in chrome browser:
a) Postman extension: https://chrome.google.com/webstore/detail/postman-rest-client/fdmmgilgnpjigdojojpjoooidkmcomcm?hl=en
b) Advance RESTClient extension: https://chrome.google.com/webstore/detail/advanced-rest-client/hgmloofddffdnphfgcellkdfbfbjeloo

in firefox browser:
a) Poster add on: https://addons.mozilla.org/en-US/firefox/addon/poster/
b) RESTClient add on: https://addons.mozilla.org/en-US/firefox/addon/restclient/

from CLI(command line interface)
curl -v "http://[API call URL]"


What includes a proper API testing?
a) Planning your test cases meticulously - to include below points
b) Each parameters in a API request should be tested for boundary value analysis, null values, negative scenarios.
c) Every error code should be checked so that API code is smart enough to throw an error when encounters something un-expected in an API request.

What are the limitations of API testing?
a) No GUI to help testers with input values
b) A tester should have some coding knowledge
c) Request, response paramaters including error codes should be known to a tester
d) Validation of expected outputs and actual outputs are difficult for a tester to understand

How can API testing be automated?
You can use Jmeter to automate the API testing. Jmeter uses Java.

Sunday, June 16, 2013

Load Testing - Jmeter Vs Siege

- Jmeter comes with a GUI to create/run load tests, while Siege is command line tool
- Jmeter has tons for features that can be used while testing an entire website - with muliple pages, while Siege has limited options to be used
- Siege is fast to setup and run while Jmeter takes time to setup as it involves multiple steps
- Jmeter is faster to run for n concurrent users than Seige
- Jmeter has broad set of options for results analysis while Siege has one summary of results
- Seige is good for a quick load testing of a webpage while Jmeter is good for a wide variety of tests to be run at a single time
- Jmeter has several plugins to enhance its load testing features and analysis while Siege lacks in plugins
- Sometimes, Siege can give false results thinking better performance while Jmeter is quite accurate in its results

Hence, I prefer Jmeter in most of the load testing requirements, while I use Siege for a quick load test.

Saturday, June 15, 2013

Automation testing using TestComplete

For more than a year, I've been working on automation of functional testing, regression testing using TestComplete(http://smartbear.com/products/qa-tools/automated-testing-tools). It's a paid automation tool.

It's an little tricky to learn and use but quite similar to Selenium. You can use xpath, record and play to script test cases.

Pros:
- similar to Selenium IDE, you can record and play test scripts
- similar to Selenium RC, you can create test scripts in VBScript, JScript, DelphiScript, C++Script or C#Script. (personally, I liked VBScript)
- Test results logs helps in finding precisely the issue where test failed
- tests can be recorded in keywork driven or screen capture modes
- tests can be created for regression, functional, DDT (data driven testing), ODT(object driven testing), and so on
- can easily do cross-browser testing

Cons:
- automated tests can not be run on Mac OSX
- no support for mobile testing automation (though there is a package  'seetest' which can be integrated with TC)
- it can not read xpath values for browsers other than IE, Firefox, chrome, Safari.

Please read this book on TestComplete(reviewed by me): http://www.packtpub.com/testcomplete-cookbook/book 

Tuesday, June 5, 2012

Browser cookies and its contents

Are you cookied? Tips to look for your cookies:

in chrome browser: chrome://settings/cookies, click on individual cookies to know its contents

in Firefox browser: options -> privacy -> remove individual cookies, click on individual cookies to know its contents

in IE 9: tools->internet options->general->settings->view files -> all files starting with cookie:

Tuesday, March 13, 2012

GooglePlay and its bugs

I found these bugs with Google Play:

1. Google Support page link from the Google Play has this JavaScript error(and the support page comes blank in Internet Explorer 8):


Webpage error details

User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729)
Timestamp: Tue, 13 Mar 2012 20:00:17 UTC


Message: HTML Parsing Error: Unable to modify the parent container element before the child element is closed (KB927917)
Line: 0
Char: 0
Code: 0
URI: http://support.google.com/googleplay/bin/answer.py?hl=en&answer=1229970

2. In Google play, I see that while its uploading my music from Itunes, the music file number being uploaded is different from the one I see in the taskbar(screenshot shows file #88 while taskbar Googleplay icon says#92):




Friday, March 9, 2012

Time to say 'Goodbye USA'

It has been almost 8 yrs since I came to study in US. Now, after this long time, I'm excited because I'm going back to my home country- India on 23rd March.

It is time to say 'Goodbye USA' as I don't know if I will be back or not. Right now, I can only think of good memories of this country. It has been a long journey here as I got my MS degree, good job in NYC, my better half  and visited many beautiful places here. I learnt a lot of good things from this country and will always remember them and use them in India.

India has become a land of opportunity now with its booming economy with billion+ people and its billion possibilities in any field. Specially in the field of new businesses, its a hot market. A lot of startups are coming up everyday and indian market is so big that it can digest even more of them in future.

I see a lot of opportunity to work, invest, start something of my own soon in India.

Thanks to USA and I'm coming back, India!!