Testing.

Monday, 10 September 2018

Selenium Webdriver tutorial: How to Configure Ruby in Eclipse for Automation Scripting.


In this article we are going to learn how to setup Selenium with Ruby, our tests will be written in Ruby while interfacing to Selenium’s API through ‘Gems’ on top of a specific IDE.
These are the steps to run a test in Selenium with Ruby using eclipse IDE:
  1. Download and install Ruby.
  2. Install Java (Optional but recommended for eclipse)
  3. Install Eclipse IDE.
  4. Configure Ruby with Eclipse.

Download and install Ruby

There are number of ways to install ruby, but in this article, we will use simplest way i.e. Ruby installer. To download ruby installer, enter: https://rubyinstaller.org/downloads/ and download the latest version of ruby and install it on your machine.

To know how to install ruby and set environment variable for ruby in details, enter: https://programmingyouself.blogspot.com/2018/09/how-to-install-and-set-environment.html



When installation is over, go to the “C:” drive and notice a new library is created like – “Ruby25-x64” (Here number indicates the version of the ruby)

Download & Install Java (Optional but recommended for eclipse)

To download and install latest version of Java, enterhttp://www.oracle.com/technetwork/java/javase/downloads/jdk10-downloads-4416644.html

Download & Install Eclipse IDE

To download and install latest version of Eclipse, enter: https://www.eclipse.org/downloads/




Here installation is over now launch the Eclipse by clicking eclipse Icon



Here our eclipse is launched successfully now its time for configuring ruby with eclipse

Configure Ruby with Eclipse

To configure ruby with eclipse Click on “Help=> Install new Software


Now Select All Available Sites (This process takes time)


Now Search for “Programming languages” and expand it


Now Search for “Dynamic Languages-Toolkit- Ruby Development Tools”, select it and click on “Next” button

At this point wait until installation finished and restart Eclipse


Now we must configure Ruby’s interpreter that will be working with Eclipse. For this click on “Windows=>Preferences” and choose Ruby’s Libraries


Now Click on “Ruby=>Interpreter=>Add


Now Click on “Browse” option, go to Ruby’s bin folder, select “ruby.exe” file and click on “OK” button.


Here our ruby is configured with eclipse for automation script now we can start scripting.

Friday, 7 September 2018

Selenium Webdriver tutorial: How to Install and set environment variable for ruby programming language on Windows-10.



  1. Download and install Ruby Installer 
  2. Set Environment Variable for Ruby

Download Ruby Installer. 


Go to downloaded location and double click on Ruby installer





Set Environment Variable for Ruby

  1. To set Environment variable first we need to check where ruby is installed
  2. To check go to the "C:\" and find ruby folder.
  3. Open Ruby folder and go to the bin folder and copy path of the ruby bin folder.
     For me its like this : C:\Ruby25-x64\bin

  • Right Click on “My Computer” => “Properties

  • Click on "Advance System settings"
  • Click on "Environment Variables"

  • Select "Path" and Click on "Edit" button in System Variables

  • Click on "New" button , "Paste" the ruby bin folder's Path here and and Click on "OK" button.

Now check whether ruby is installed successfully,  here we go to the command prompt and type the following command then hit the enter button

        Command:  ruby -v

Ruby on rails: What is Ruby programming language?

Introduction of Ruby Programming

  • Ruby is a well-known open source object-oriented programming language specially made for development client environments.
  • It has easy and clean syntax, few syntax are related to the C and C++, so it will be easy for us to understand and writing ruby code.
  • It is interpreted programming language that means whatever the code we are going to write it will be interpreted directly, it will not be compiled.
  • Ruby is also providing easy connection between different databases, we can easily make connection between MYSQL, DB-2 and Oracle etc.
  • Ruby has a rich set of built in functions which can be used directly into Ruby script.
  • Ruby is interactive in nature we can use Ruby shell and get command result immediately
  • We can write Ruby code either in the "Notepad or Notepad++", It has its own editor called RubyMine we can use it for 30 days trial version

History of Ruby

Ruby is developed by Yukihiro “Matz” Matsumoto in 1990 in Japan. His favorite languages (Perl, Smalltalk, Eiffel, Ada and Lisp) to form a new language that balanced functional programming with imperative programming.


Idea of Ruby

At that time Perl was a scripting language but comes under the category of TOY language. Python is not fully object-oriented language.  But Yukihiro “Matz” Matsumoto wanted a programming language which is completely object oriented and should be easy to use as a scripting language. At that time, he searched for this type of language, but could not find any language which matches with his requirement then he decided to develop one and developed new programming language called ruby.

Features of Ruby

  • Fully Object-oriented
  • Flexibility
  • Expressive feature
  • Dynamic typing and Duck typing
  • Exception handling
  • Garbage collector
  • Portable
  • Statement delimiters
  • Variable constants
  • Naming conventions
  • Keyword arguments
  • Method names
  • Singleton methods
  • Missing method
  • Visual appearance
Fully Object oriented
Ruby is fully object-oriented programming language. Each value in ruby is an object. Every object has a class and class has a super class.
Every code has their properties and action.
It is influenced with Smalltalk language.

Flexibility
It is a flexible programming language, programmer can easily remove, redefine or add existing parts to it. Ruby allows its users to freely alter its part as their wish.

Dynamic typing and Duck typing
Ruby is a dynamic typing programming language. Whatever the programs we write in ruby it is not compiled that’s why its called as interpreted programming language also.
All classes modules and methods are built by the code when it run.
Variables in ruby are loosely typed, that means any variable can hold any type of object. When a method is called on an object, ruby only looks up the name irrespective of the type of object.  

Tuesday, 4 September 2018

C Turorial : Buffer meaning in C progamming language.


  • Temporary storage area is called as buffer.
  • In implementation when we are passing more than required number of input values then automatically remaining values are stored into standard input buffer and these values automatically will pass to next input functionality.    
Example:
         int main()
         {
              int value1, value2;
              clrscr();
              printf ("\n Enter Value-1: ");
              scanf("%d", &value1);
              printf ("\n Enter Value-2");
              scanf("%d", &value2);
              printf("\n Sum of Value1+Value2 = %d", value1+value2);
              getch();
              return 0;
         }
Output:
         Enter Value-1: 10  20
         Enter Value-2: 
         Sum of Value1+Value2 = 30
  • In implementation when we require to remove temporary data form standard input buffer then go for flushall() or fflush().
flushall():-
  • flushall() is predefined function which is declared in <stdio.h>, by using this function we can remove the data from standard input buffer.
  • When we are working with flushall() it doesn't return any value and doesn't take any parameter.
Syntax:-
      void flushall(void);

fflush():-
  • fflush() is predefined function declared in <stdio.h>, by using this function we can clear standard input buffer data.
  • fflush() require one argument of type FILE* and doesn't returns any value.
Syntax:-
      void fflush(FILE*stream)

Example: 
          #include<stdio.h>
          #include<conio.h>
          int main()
         {
              int value1, value2;
              clrscr();
              printf ("\n Enter Value-1: ");
              scanf("%d", &value1);
              printf ("\n Enter Value-2");
              flushall(); //fflush(stdin);
              scanf("%d", &value2);
              printf("\n Sum of Value1+Value2 = %d", value1+value2);
              getch();
              return 0;
         }
Output:
         Enter Value-1: 10  20  30  //here only 10 will be accepted by compiler 20 and 30 will be  
         Enter Value-2: 30              // cleared by flushall()
         Sum of Value1+Value2 = 40

Saturday, 24 March 2018

C programming language: C program to find an element in the array using binary search.

#include<malloc.h>
#include<conio.h>
#include<stdlib.h>
#include<stdio.h>

int main()
{
int *arr, SIZE, max,min, mid, flag=0;
int data, pos, i;
printf("\n Enter Array Size: ");
scanf("%d",&SIZE);
arr=(int *)calloc(SIZE,sizeof(int));
printf("\nEnter Array Elements: ");
for(i=0;i<SIZE;i++)
scanf("%d",&arr[i]);
printf ("\nEnter Data to be search: ");
scanf("%d",&data);
max=SIZE-1;
for(min=0;min<=max;min++)
{
if(arr[min]==data)
{
pos=min+1;
flag=1;
break;
}
mid=(min+max)/2;
if(arr[mid]<=data)
{
if(arr[mid]==data)
{
pos=mid+1;
flag=1;
break;
}
min=mid;
}
else
{
max=mid-1;
min=0;
}
}
if(flag==1)
printf("\n %d is found at %d Position: ",data,pos);
else
printf("\n %d IS NOT FOUND: ",data);
free(arr);
arr=NULL;
getch();
return 0;
}