GitHub with Robot Framework

Git : Git is an open-source distributive version control system, we can also call Git as a type of Backup, Git holds the history of all kinds of operations that you have done in each updated version, it also tracks the files, holds commit history, and allows you to make changes, undo changes you have made before. Git allows one or more people to work as a team on the same project, and we call this process as a collaboration.

Git Workflow Cycle

Here we will go through the basic Git workflow and some basic key concepts.

basic-workflow

Working Directory:

A working directory is used to modify the files, where it is a directory or folder on the computer which contains all the project or application files. The files within the working directory may or may not be controlled by the Git. There will be a hidden folder called .git folder that contains the actual git repository.

Staging Area:

The staging area is also called Index, where the staging area holds /keeps all the files that are in the queue for the next commit. The files which are present in the staging area are not committed yet. we can move the files in and out from the staging area without affecting the git repository and its history of changes.

Once you perform commit operation, git sends files from the staging area to the repository. Once you complete the push operation, it will permanently store the changes in the git repository.

Git Repository:

Git Repository is the one that contains all the files concerning the specific project application. Git Repository also includes a commit history and unique configurations in it.

The Complete GitHub Tutorial

GitHub

GitHub is a Web-Based Hosting service mostly used for version control Systems through Git. It lets you and others work together on projects from anywhere.

Now to understand the entire Git workflow in the local and Remote side, we need to create a remote repository by using the GitHub. Then we can replicate the remote repository in the local system.

  • Once we have done with all the operations, finally we can synchronize back to the Github. Now let's see how to create a GitHub account.
  • Open a browser and navigate to https://github.com/
  • If you already have an account means your directed to sign in a page or else go to sign up.
    github-signup-page
  • Enter Valid credentials like username, email id, and password and click on sign up.
  • Now it will take you the Welcome page, and there, you need to select the plans as Github is an opensource, and it will offer free service hence choose the plans according to your need.
    select-plan-github
  • Now your Github account has created.

Working with Robot Framework Jenkins

Creating a Git Repository

  • Open Github account, and in the main page right corner, click on the + sign, you will suggest with a new repository, new project, etc.. select New Repository.new-repo
  • Enter the new repository name you wanted to create and select initialize this repository with README.md and click on Create Repository.

create-github-demo-repo



Web Elements of Robot Framework

Configure Github Account

Before we are proceeding further with Git, we need to configure the Git repository. Git Requires two information such as username and email id.

  • Open Git Bash.
  • Enter the below Commands in the command prompt.
  • $ git config --global user.name "your username"
  • $ git config --global user.email "your email id"
    config-github-ac
  • Navigate to Github account and open your new repository, and now you wanted to copy remote repository into the local system through a process called cloning.
  • Copy the repository URL from the main repository page.
    copy-github-demo-url
  • Open a command prompt and enter the command, as shown below.
  • $ git clone https://github.com/goldsi/github_demo.git
    cloning-github-repo
  • Once we have done with cloning operation pass the command like $ ls then it will list all the files which are present in the project folder, then do cd github_demo/ you will be directed to the github_demo.
  • Now pass $ git status command the repository tell us that it is on its master branch where the master branch is the default branch for Git Repository.
  • Let us see the relationship between the working directory, staging area, local repository, and remote repository by adding some text files.
  • First, create a simple text file by using the echo command.
  • $ echo "test quick start" >> great.txt
  • creating-text-file-great
  • Now press ls command, you can see the great.txt file in the working directory.
  • Use $ cat great.txt a command to see the content of the text file.
  • The great.txt file is showing under an untracked file because it does not add to the Git yet.
  • Now, let's add a text file to the Git by using the below command.
  • $ git add great.txt
  • Then check git status, it will show you a file in the staging area.
    adding-file-to-staging-area
  • Commit the file in the staging area using the command
  • $ git commit -m "adding text great txt file".
  • Hence it will give you the below output
    commit-great-text-file
  • Since once you have done the commit operation, git returns as the working directory are clean.
  • But Still, our file is in the local repository, its still not on the Github.
  • Add these files to Github by push operation.
  • $ git push origin master
    github_demo_push
  • Here push command specifies the remote name, which is the origin, which is set up when we did cloning.
  • Once done with the push operation, we can check our results by refreshing the main page we will be able to see the great.txt file on the remote repository on Github.
    text-file-on-repo
  • If everything works well, then we can see the text inside the great.txt file.
    text-file-content

User Defined Keywords Using Python in Robot Framework

Git Bash

Git for Windows provides a BASH emulation used to run Git from the command line.

Installation of Git Bash

Navigate to https://gitforwindows.org/, gitforwindows page will open as shown below and then click on the download button.

git-for-windows-page

Once the application has downloaded, click on the download file and select Next, the application starts installing on your system. Once it completes installing, click on Finish

Go to the project folder and right-click on the folder, in the drop-down list you will find the GitBash here option.

right-click-on-desktop-application

If you click on the Git Bash Here, the Git bash emulator will open.

git-bash-emulator-page

Web Services Automation in Robot Framework

GIT Steps to push Flight application code to Remote repository

Create a new repository on GitHub. To avoid errors, do not initialize the new repository with README, license, or gitignore files. You can add these files after your project has been pushed to GitHub. I have created my new repository Flight Application as shown below

successfully-created-my-new-repository-Flight-application

Open Git Bash from your project folder

git-bash-emulator-page

Configure the Github username and password to create our identity by using the command $ git config --global user.name "snapp123" and the password $ git config --global user.email kantaraja1965@gmail.com

intializing-user-name-and-password

Initials the local directory as a Git repository by using the command $ git init

initials-local-repo-as-git-repo

Add the files in your new local repository by using the command $ add .

add-file-to-git-repo

After adding the file from the local repository, we need to commit by using the command $ git commit -m "This is my First Commit", once you commit the below files, are created in the remote repository.

commit-message

Next step is to add the origin/URL of the git repository, go to the GitHub page you will find the Github URL as shown in the below image.

git-repository-url

Copy and paste this in the git bash by using the command $ git remote add origin https://github.com/snapp123/Flight-Application.git, now we have connected our local repository to the remote repository.

Verify our repository by using the command $ git remote -v, now you can see our remote repository Flight Application fetch and push message, as shown below.

verifying-remote-repository

Now we have to push the changes in your local repository to GitHub by using the command $ git push origin master, once you run this command you will be prompted to enter the username and password

prompted-to-enter-user-name-and -password

Enter the username and password and click on Login, you can see the push message in the git bash, as shown below.

git-push-message

Now go to the GitHub and open your repository, you can see all the keywords and test cases created over there.

flight-application-repo-with-keywords

Comment / Suggestion Section
Point our Mistakes and Post Your Suggestions