17 | Automated Testing

Published on Aug 13, 2021 | By Tesvan team

Automated Testing Method

 

Automated testing is the application of software tools to automate a human-driven manual process of reviewing and validating a software product. Most modern software projects now include automated testing from inception.

 

Selenium Locators

Locator is a command that tells Selenium IDE which GUI elements (say Text Box, Buttons, Check Boxes etc) its needs to operate on.  Identification of correct GUI elements is a prerequisite to creating an automation script. But accurate identification of GUI elements is more difficult than it sounds.

The choice of locator depends largely on your Application Under Test. In this tutorial, we will toggle between Facebook, new tours.demoaut on the basis of locators that these applications support. Likewise in your Testing project, you will select any of the above-listed element locators in Selenium webdriver, based on your application support.

        

Locating by ID

This is the most common way of locating elements since ID's are supposed to be unique for each element.
Target Format: id=id of the element

       

Locating by Name

Locating elements by name are very similar to locating by ID, except that we use the "name=" prefix instead.
Target Format: name=name of the element

       

Locating by Name using Filters

Filters can be used when multiple elements have the same name. Filters are additional attributes used to distinguish elements with the same name.
Target Format: name=name_of_the_element filter=value_of_filte

      

Locating by Link Text

This type of CSS locator in Selenium applies only to hyperlink texts. We access the link by prefixing our target with "link=" and then followed by the hyperlink text.
Target Format: link=link_text

        

Locating by CSS Selector

CSS Selectors in Selenium are string patterns used to identify an element based on a combination of HTML tag, id, class, and attributes. Locating by CSS Selectors in Selenium is more complicated than the previous methods, but it is the most common locating strategy of advanced Selenium users because it can access even those elements that have no ID or name.

CSS Selectors in Selenium have many formats, but we will only focus on the most common ones.

  • Tag and ID
  • Tag and class
  • Tag and attribute
  • Tag, class, and attribute
  • Inner text

When using this strategy, we always prefix the Target box with "css=" as will be shown in the following examples.

         

Locating by CSS Selector - Tag and ID

Again, we will use Facebook's Email text box in this example. As you can remember, it has an ID of "email," and we have already accessed it in the "Locating by ID" section. This time, we will use a Selenium CSS Selector with ID in accessing that very same element.

SyntaxDescription
css=tag#id- tag = the HTML tag of the element being accessed
- # = the hash sign. This should always be present when using a Selenium CSS Selector with ID
- id = the ID of the element being accessed  

         

Locating by CSS Selector - Tag and Class

Locating by CSS Selector in Selenium using an HTML tag and a class name is similar to using a tag and ID, but in this case, a dot (.) is used instead of a hash sign.

SyntaxDescription
css=tag.class-  tag = the HTML tag of the element being accessed
-  . = the dot sign. This should always be present when using a CSS Selector with class
-  class = the class of the element being accessed  

          

Locating by CSS Selector - Tag and Attribute

This strategy uses the HTML tag and a specific attribute of the element to be accessed.

SyntaxDescription
css=tag[attribute=value]-  tag = the HTML tag of the element being accessed
-  [ and ] = square brackets within which a specific attribute and its corresponding value will be placed
-  attribute = the attribute to be used. It is advisable to use an attribute that is unique to the element such as a name or ID.
-  value = the corresponding value of the chosen attribute.  

        

Locating by CSS Selector - tag, class, and attribute

SyntaxDescription
css=tag.class[attribute=value]-  tag = the HTML tag of the element being accessed
-  . = the dot sign. This should always be present when using a CSS Selector with class
-  class = the class of the element being accessed
-  [ and ] = square brackets within which a specific attribute and its corresponding value will be placed
-  attribute = the attribute to be used. It is advisable to use an attribute that is unique to the element such as a name or ID.
-  value = the corresponding value of the chosen attribute.  

                

Locating by CSS Selector - inner text

As you may have noticed, HTML labels are seldom given id, name, or class attributes. So, how do we access them? The answer is through the use of their inner texts. Inner texts are the actual string patterns that the HTML label shows on the page.

SyntaxDescription
css=tag:contains("inner text")-  tag = the HTML tag of the element being accessed
-  inner text = the inner text of the element  

          

API Testing

API (Application Programming Interface) is a computing interface which enables communication and data exchange between two separate software systems. Software system that executes an API includes several functions/subroutines that another software system can perform. API defines requests that can be made, how to make requests, data formats that can be used, etc. between two software systems.

API testing is a software testing type that validates Application Programming Interfaces (APIs). The purpose of API Testing is to check the functionality, reliability, performance, and security of the programming interfaces. In API Testing, instead of using standard user inputs(keyboard) and outputs, you use software to send calls to the API, get output, and note down the system's response. API tests are very different from GUI Tests and won't concentrate on the look and feel of an application. It mainly concentrates on the business logic layer of the software architecture.

API automation Testing requires an application that can be interacted via an API. In order to test an API, you will need to

  • Use Testing Tool to drive the API
  • Write your own code to test the API

         

Test Cases for API Testing

Test cases of API testing are based on։

  • Return value based on input condition: it is relatively easy to test, as input can be defined and results can be authenticated
  • Does not return anything: When there is no return value, a behavior of API on the system to be checked
  • Trigger some other API/event/interrupt: If an output of an API triggers some event or interrupt, then those events and interrupt listeners should be tracked
  • Update data structure: Updating data structure will have some outcome or effect on the system, and that should be authenticated
  • Modify certain resources: If API call modifies some resources, then it should be validated by accessing respective resources

           

Docker

Docker is a software development platform for virtualization with multiple Operating systems running on the same host. It helps to separate infrastructure and applications in order to deliver software quickly. Unlike Hypervisors, which are used for creating VM (Virtual machines), virtualization in Docker is performed on system-level, also called Docker containers.

As you can see the difference in the image below, Docker containers run on top of the host's Operation system. This helps you to improves efficiency and security. Moreover, we can run more containers on the same infrastructure than we can run Virtual machines because containers use fewer resources.

Why use Docker?

  • Docker is computer software used for Virtualization in order to have multiple Operating systems running on the same host
  • Docker is the client-server type of application which means we have clients who relay to the server
  • Docker images are the "source code" for our containers; we use them to build
  • Dockerfile has two types of registries 1.) public and 2)private registries
  • Containers are the organizational units of Docker volume. In simple terms, an image is a template, and a container is a copy of that template. You can have multiple containers (copies) of the same image.

   

Docker Architecture

Now in this Docker container tutorial, let's talk about Docker main components in the Docker Architecture:

    

Docker Engine

Docker is the client-server type of application which means we have clients who relay to the server. So the Docker daemon called: dockerd is the Docker engine which represents the server. The docker daemon and the clients can be run on the same or remote host, and they communicate through command line client binary, as well as a full RESTful API to interact with the daemon: dockerd.

     

Docker Images

Docker images are the "source code" for our containers; we use them to build containers. They can have software pre-installed which speeds up deployment. They are portable, and we can use existing images or build our own.

     

Docker Registries

Docker stores the images we build in registries. There are public and private registries. Docker company has public registry called Docker hub, where you can also store images privately. Docker hub has millions of images, which you can start using now.

      

Docker Containers

Containers are the organizational units and one of the Docker basics concept. When we build an image and start running it; we are running in a container. The container analogy is used because of the portability of the software we have running in our container. We can move it, in other words, "ship" the software, modify, manage, create or get rid of it, destroy it, just as cargo ships can do with real containers.

In simple terms, an image is a template, and a container is a copy of that template. You can have multiple containers (copies) of the same image.

Below we have an image which perfectly represents the interaction between the different components and how Docker container technology works.

       

Jenkins

Jenkins is an open-source Continuous Integration server written in Java for orchestrating a chain of actions to achieve the Continuous Integration process in an automated fashion. Jenkins supports the complete development life cycle of software from building, testing, documenting the software, deploying, and other stages of the software development life cycle.

Jenkins is a widely used application around the world that has around 300k installations and growing day by day. By using Jenkins, software companies can accelerate their software development process, as Jenkins can automate build and test at a rapid rate.

It is a server-based application and requires a web server like Apache Tomcat. The reason Jenkins software became so popular is that of its monitoring of repeated tasks which arise during the development of a project. For example, if your team is developing a project, Jenkins will continuously test your project builds and show you the errors in early stages of your development.

     

What is Continuous Integration?

Continuous Integration is a process of integrating code changes from multiple developers in a single project many times. The software is tested immediately after a code commit. With each code commit, code is built and tested. If the test is passed, the build is tested for deployment. If the deployment is successful, the code is pushed to production.

This commit, build, test, and deploy is a continuous process and hence the name continuous integration/deployment.

    

How does Jenkins work?

Jenkins is a server-based application and requires a web server like Apache Tomcat to run on various platforms like Windows, Linux, macOS, Unix, etc. To use Jenkins, you need to create pipelines which are a series of steps that a Jenkins server will take. Jenkins Continuous Integration Pipeline is a powerful instrument that consists of a set of tools designed to hostmonitorcompile and test code, or code changes, like:

  • Continuous Integration Server (Jenkins, Bamboo, CruiseControl, TeamCity, and others)
  • Source Control Tool (e.g., CVS, SVN, GIT, Mercurial, Perforce, ClearCase and others)
  • Build tool (Make, ANT, Maven, Ivy, Gradle, and others)
  • Automation testing framework (Selenium, Appium, TestComplete, UFT, and others)

       

Jenkin History

  • Kohsuke Kawaguchi, a Java developer, working at SUN Microsystems, was tired of building the code and fixing errors repetitively. In 2004, created an automation server called Hudson that automates build and test task.
  • In 2011, Oracle who owned Sun Microsystems had a dispute with Hudson open source community, so they forked Hudson and renamed it as Jenkins.
  • Both Hudson and Jenkins continued to operate independently. But in short span of time, Jenkins acquired a lot of projects and contributors while Hudson remained with only 32 projects. With time, Jenkins became more popular, and Hudson is not maintained anymore.

 

 

Useful links
1. Automation testing article/eng/
2. Selenium as an automation testing tool article/eng/
3. Selenium locators article/eng/
4. Docker article/eng/
5. API testing article/eng/
6. Jenkins article/eng/
7. Automation testing video tutorial/eng/
8. Automation testing video tutorial/arm/
9. Automation testing video tutorial/rus/
10. Locators in Selenuim video tutorial/eng/
11. Xpath in Selenium video tutorial/eng/
12. Jenkins video tutorial/eng/
13. Docker video tutorial/eng/

Next Lessons


19 | Functional testing

Aug 13, 2021

Functional testing What does Functional Testing check?Functional Testing is a type of software testing that validates the software system against the functional...

By Tesvan team

18 | Manual Testing VS Automation Testing

Aug 16, 2021

Manual Testing VS Automation Testing     Useful links1. Manual testing vs Automation testing article/eng/2. Manual testing vs Automation testing article/rus/3....

By Tesvan team

20 | Non-functional testing

Aug 16, 2021

Non-funtional testing Non-Functional Testing is defined as a type of Software testing to check non-functional aspects (performance, usability, reliability, etc)...

By Tesvan team

21 | Maintenance testing

Aug 17, 2021

Maintenance Testing is done on the already deployed software. The deployed software needs to be enhanced, changed or migrated to other hardware. The Testing don...

By Tesvan team

22 | Defect, Error, Bug, Failure

Aug 17, 2021

What is a Defect  The variation between the actual results and expected results is known as defect. If a developer finds an issue and corrects it by himself in ...

By Tesvan team

Interesting For You



17 | Automated Testing

Aug 13, 2021 | By Tesvan team

Automated Testing Method Automated testing is the application of software tools to automate a human-driven manual process of reviewing and validating a software...

16 | Manual testing

Aug 13, 2021 | By Tesvan team

Manual testing method   Useful links1. Manual testing article/eng/2. Manual testing article/eng/3. Manual testing article/rus/4. Manual testing video tutorial/e...