Wednesday, November 8, 2017

NeoLoad - Performance and Load testing



This blog we will talk about NeoLoad for Performance testing.

Neoload is a paid application for performance testing but it has demo feature which one can check and try the application before buying the full Software.

To download a demo one has to visit -

https://www.neotys.com/

From there we can get a free version though free version which will give upto 50 concurrent users
to put the load on your website.

When you launch the application it will look something like below


You will observe the application has 3 tabs

1. User Paths

2. Populations

3. Monitors


1. user paths are like the paths which the application will follow while testing, you have to record the way the application should progress in your website. It will then prompt a check and inform if any requests or response is not proper.


2. Population is nothing but the environment which you want to set up so using this you can go ahead  set the browser or device you want the application to access your website from. It will emulate the specific device  and login to your website.


3. Monitors are the technology which you used on your website and the technology which you want neoload to use to access your website. It helps identifying any platform related issues while user is making a transaction with your website.


After setting this Go to Run time tab and select the load policy and Press play.

It will run for selected time and give a result like below-



It also has many good features which is available as free.


Good Tool overall. Very Easy to use.



Wednesday, October 4, 2017

Creating Exe file from a python Tkinter file application.

Today we will discuss about creating exe file from python for making windows application.
For this the basic requirement is Python to be installed and working on SUT and then the pyinstaller being install in the system.

To install pyinstaller we can do -

pip install pyinstaller for windows user
sudo pip install pyinstaller for Linux user.

This pyinstalled builds an exe from the py file which user can run in windows platform.

To make this happen we need a python script that is made with Tkinter which is used for Python UI development for windows platform.

For Python 2.7 the name of the package is Tkinter for Python 3 its called tkinter.
Now after we have all our requirement fulfilled next step is to create the exe.

For that the simple command is

pyinstaller.exe --onefile --windowed  file_name.py

This is will start the packaging for the exe file. Note here one file means it will make a one file installer, other type of packaging system is also available with pyinstaller like folder package etc.
Windowed parameter tells tells the pyinstaller that the exe is a windowed process rather than a background process.

Two folder will be generated - dist is the main folder which will the have the exe file and which we can export or sell to customers.


Something look like below -





Using python 2.7 with selenium and Unittest to automate a test step for a website.

Today i will tell how to Write a unit test for a test step involving checking 3 dynamic links that changes over time and the validity of those links.

For this the requirement is very easy we need Python 2.7 and selenium installed in system under test.
To install Python one can download from

https://www.python.org/download/releases/2.7.7/


After successfully installing python go to your cmd prompt and check for python by typing python and pressing enter.
If the python interpreter starts we are ready to go to next step else one needs to put the bin directory path in the system path. Google " how to set python path in system path" if python is not set in the system path.

Then we need to install selenium by simply using pip -

pip install selenium for windows
sudo pip install selenium for linux users.

After this we are ready to automate the site say "Example Site"

Next create a python file and name it as -TC_001.py

Write click on the file and open with IDLE.
For using unittest we have to use setup, test and teardown methods for the unittest to understand what we intend to do with the class.

In the teardown we have to create instance of the gecko or chrome driver which ever we are working with like this.


def setUp(self):
        # create a new Firefox session
        self.driver = webdriver.Firefox()
     
This tells the unittest to create a firefox driver session to interact with the browser.

Next we have to write the test method that has the core logic of test steps.

def test_verify_links_not_same(self):
        log.warning("Starting test of verifying links are not same below search box")
        self.driver.get("https://examplesite.com/")
        log.warning("opening site")

Now we need to parse the links and open each page individually to confirm that the links are working and then take a screenshot for our confirmation.

        temp = ""
        target = self.driver.find_elements_by_xpath('//*[@id="search-bar"]/div/div[1]/span')
       
        for paths in target:
            temp = temp + paths.text
           
        links =  ' '.join(temp.split(' ')[3:])
        log.warning("the links below the search box are " + str(links))

        path1 = self.driver.find_element_by_xpath('//*[@id="search-bar"]/div/div[1]/span/a[1]').click()
        time.sleep(3)
        self.driver.save_screenshot("Link1.png")
        self.driver.back()
        time.sleep(3)       
        path2 = self.driver.find_element_by_xpath('//*[@id="search-bar"]/div/div[1]/span/a[2]').click()
        time.sleep(3)
        self.driver.save_screenshot("Link2.png")
        self.driver.back()
        time.sleep(3)
        path3 = self.driver.find_element_by_xpath('//*[@id="search-bar"]/div/div[1]/span/a[3]').click()
        time.sleep(3)
        self.driver.save_screenshot("Link3.png")
        self.driver.back()
        time.sleep(3)

       
        log.warning("test_verify_links_not_same completed")



Here a thread sleep is put for any server lag that may happen while running the test.
Note: We are not handling any negative scenarios that may arise while running the test.
we can use try catch or explicit waits or even web driver wait before each element is interacted with (driver find by element).
After this we need to clean the test after running i.e close the driver which is running in teard own method.

         def tearDown(self):
       
               # close the browser window
                self.driver.quit()

This is how we can write a python unit test to automate a test step of verifying links in webpage and take a screenshot of each link after opening.






Wednesday, September 27, 2017

Appium integration with windows platform.

Today i will talk about Appium which is automation tool and is open sourced, used to automate mobile applications. Appium is written in node.js and supports multiple languages to be implemented for iOS or Android mobile devices. We can test web/native applications using appium in mobile device.

This post is regarding how to integrate appium with Windows platform as it has many dependencies to get installed.

Dependencies of installing appium on widows -

  • JDK
  • Android SDK (adb/uiautomator)
  • Node JS
  • MS .Net Framework
  • Appium Client
  • An ide to work with code.
Installing all of the above will ensure that appium has a working environment in windows to be runnable.

After Installing the Appium client and its dependency launch the appium client. It will look like this in the below picture.


Basically it has 3 tabs Single, advanced and presets.

Single - 

You can select the host and port ip addresses here generally its kept as 0.0.0.0 and 4723 as default values.

Advanced - 

This will have some extra options like saving log path, binary path for chromedriver in android, executeAsync callback host and port in iOS. We can also save our presets or settings into a single name and run it every time with the selected settings every time we select the named preset.

Preset -

Contains a list of saved preset saved by user with required settings. User can load the preset and the saved settings will be loaded.

Start Server starts the appium server with the selected settings.

A started server will look like below picture -



Now environment is running all that is needed is a android device to connect and some code to run.
Remember to verify the developer options is turned on in your android device and as well usb debugging is turned on. After connecting the device do a adb device on the command prompt to check if device is detected by the system. If no device is shown you need to install device driver for your mobile device on your system.

If everything goes right the device can now be accessible through the appium intermediate where you can test application through code and automate user steps on mobile device.

P.S. Android setup installs adb and uiautomator which are useful tools while automating through appium.

Tuesday, September 26, 2017

Using Custom Commands to simplify process in NightwatchJS

Nightwatch js is a package which is used to test Web UI in browsers using selenium and javascript. Today i will tell you about a feature in nightwatchjs which is Custom commands which can be used to inject functionality to a method manually using dependency injection.

First we need to have it installed in the system by using the below command -

  • sudo npm install --save nightwatch
This will install the package locally. We also have to remember that node must be installed in the system to run the command node package manager i.e. npm. We need to then run the selenium server at the background. Download the jar and run the jar as a background process -
  • java -jar selenium-server-standalone-3.4.0.jar
It will also need chromedriver or geckodriver to be in system path to run them successfully.

A nightwatchjs requirement is that it should have a config file which is a conf.js or a json file that links all the resources to run the tests. Then it should have a tests folder where all the tests are suppose to reside. Something like below picture - 

Now after writing the tests one has to just run node 
  • nightwatch tests 
As we are keeping the test steps inside tests folder, on calling tests it will run all the tests inside the tests directory.

Now to come to custom commands we need to create folder called custom commands and keep the code inside which we want to run as a dependency for other tests to run something like below picture,


Now we have to link the custom command in the config file some thing like below picture,



Finally we call the login custom command inside each tests to perform the step as a prestep.


P.S. This feature is same like BeforeEach functions in other testing frameworks.

Working With Postman and Nosql Mongodb.

Today i will show you how to push data into Mongodb database using Postman which is a rest api interaction tool.

First of all mongdb must be installed on system using

  • npm install -g mongoose
  • or sudo apt-get install -g mongoose (for ubuntu/linux)
After successfully installing mongoose then we need to create a schema to make a collection in the db. 


This creates a collection with title and url fields. Now we need to install postman which is available in chrome extension as well as in exe format. After installing open the postman, it should look something like this.




We need to make a server with node js which will talk with the mongodb server and listen to port 3000 and then do the POST operations.


Now go back to terminal and switch on mongodb by  typing "mongod" in terminal and press enter.

Observe the mongo server starts running.



Now go to postman and change the type of the operation to POST and the link to localhost/movie where the database is hosted.
Here we will talk with the database and add some data into the db using postman, so now go to the x-form-urlencoded option and then add key and value of title and url which are the data we want to push into the database like this -


Now press send to do the post operation and observe body sent from the server containing the sent data.
Go to localhost and try visiting the link and observe the data is now existing in database thus confirming the post data push from postman is successful.

P.S. This is a MEAN stack project which is used as an example to show the utility of postman for data pushing into mongodb using post method.

Monday, September 25, 2017

Partitioning of Extended space in a VMWare Workstation

This post i will discuss how to extend your disk space and allocate the un-allocated memory to the current system of Ubuntu 16.04 LTS .

For the first step is to increase the total memory of the vm ware through settings(VM Settings page) by clicking on expand and increase the total memory.

This step needs to be done when the Virtual Machine is not running. Then after extending the VM run the vm. The next step is to install gparted by using apt-get command.
Open a new terminal and type the below command, this will install gparted in the system.

  • sudo apt-get install gparted






The window will look like this after installing and opening gparted.

Now follow the steps to increase your sda1 partition to unallocated partition



  • Click linux swap.
  • Click on partition from menu.
  • Select Swap off option
  • Click on extended.
  • Click on Partition and click on resize move.
  • Now drag the memory partition and fill the unallocated memory.
  • Click on resize move button.
  • click on linux -swap
  • click on partition and click on resize move.
  • drag the same size partition to the end of the memory pipe.
  • Click on resize move button.
  • Click ok.
  • click on Extended.
  • click on partition and click on resize move.
  • Decrease the block to initial extended block (2GB/511MB)
  • click on resize move button.
  • Click ok.
  • Click on ext4.
  • Click on partition and click resize move.
  • Expand to the end and increase the partition memory of ext4.
  • Click on resize move button.
  • Click ok
  • Click on Edit
  • Click Apply all operation and press apply.
  • Wait for the process to complete and at the end notice the memory is increased.

At the end it will look like below picture- 



P.S. Data loss can happen while doing this steps if anything goes wrong, so better keep a back up of your files before performing these steps. I did not face any data loss while performing these steps. 


Automation Testing : A comparison of Synchronous and Asynchronous Web driver.

To start with the first one has to know the definition of synchronous and asynchronous.


  • Synchronous - That is it will run synchronously one after another.
  • Asynchronous - That is it will run independently of another.


So here the term comes when working with automation api of selenium webdriver. Selenium Webdriver is a tool that is used to automate user interaction on browsers to create a robotic environment where a task can be performed with minimal user assistance.

Selenium Webdriver supports few languages which include java, python, javascript etc.
Now when we deal with java webdriver behaves synchronously in dealing with user test steps but when we write the same code in javascript using webdriverjs the api behaves asynchronously thus steps do not wait for each other and starts getting executed together.

Selenium Webdriver in Java, python (Synchronous) -


  • Do not needs promises to work.
  • Dependent on the previous task to complete.
  • Can not run independent of previous task.
  • Slow process

Selenium WebdriverJS in Javascript (Asynchronous) -
  • Returns a promise after every webdriver call.
  • A promise can be anything value to an object that directs to the value.
  • Is denoted by then functions. 
  • It supports other framework which can work together like jasmine and make a complete phrase like  statement - then - expect.
  • Faster than Java, Python





Working on automation for java, python is one experience where as working on javascript is fully different. Here the main difference is of asynchronous behavior of js api which needs promises to support every test steps such that the test would be performed in an order.

P.S. Javascript or Java, Selenium is the best api to automate user interaction on a browser hands down.



Automation Testing With Slimerjs and CasperJS


Today i will talk about automation testing using CasperJS and SlimerJS to automate Smoke testing or simple test scenarios for a website.

So this post is intended for readers who are well versed on testing methods and tools. If you cannot understand any of the portion just google the term and research on it.

To start about Casperjs it can be downloaded from

http://casperjs.org/

or people who want to use npm they can just do the following -


  • mkdir caspertestexample
  • cd caspertestexample
  • npm init
  • npm install --save caperjs

Using the above commands creates a directory called caspertestexample, initializes the folder as a node folder and then installs the casperjs files on the local directory.

So this was about casperjs now the next step is to install slimerjs which is a support for casperjs to perform UI automation. Casperjs basically is an open source tool to navigate through websites and perform user tasks, we need a browser to do the work thus slimerjs comes into the scene. We can use phantomjs instead of slimer but it won't show ui to user to understand that the tests are being performed.

Next we need to do install slimerjs same as caperjs -

  • npm install --save slimerjs
After installing we need to create a tests folder under caspertestexample folder.
This would be like the main folder which will have all the tests.

Basically we have to write test in a javascript file and then run it using casperjs command through command line.

A sample syntax will be like - 



Now we save this file as sample.js and try to run from command prompt.

  • casperjs --verbose --engine=slimerjs test tests

What it will do it will start testing all the files that are under the tests folder one after another using slimerjs as a browser.

P.S. Slimerjs uses the mozilla gecko driver to run the tests.


About Me

Hello i am technology savvy guy who loves to learn new technology now and then. I have back ground in testing as well as in development of software for Multi National Companies.

I did my engineering in Information Technology and passed out in 2009. After then i have been working in Testing Domain and then in Development Domain.

I started as a QA Tester testing mobile applications for 3 years straight. Then i learned Android Development and switched to developing small applications for android. After finding the job quite less challenging which was to fix bug whole day that too make small changes in Excel to fix localization issues i made up my mind to resume in Testing profile.

I got an offer from a leading testing giant company which i immediately took the job. For next 2 years i was doing manual testing and automation testing using Java and selenium. I was not happy with my job as it was getting less hard day by day. It was like in 1 hr i was able to finish whole day's work. This was making me dumb and lazy.

Then i switched to Automation Testing Working on Python and Selenium for the first time which was very challenging at first but after some time became easy. I worked in that role for nearly 1 year as an Automation Engineer supporting/scripting on python.

At last after working for 6 years in industry i thought of taking a break and do full time freelancing providing solutions in testing/ development/ blogging content writing. It was like a dream job where i could learn new things every day and challenge was never less with new clients came new work culture thus making it fun and interesting.