The blog gives you idea of testing and automation testing example of selenium webdriver,SQl and Jmeter, you see the basic example of selenium web driver and get idea how to do automation testing,

Program To convert Date into Long and Vise versa

you are working on an application in which you want to convert date into Long or vise versa of the same, long intodate then use the below code.
using of long into date and date into long is depend on the code requirement or use of the programme.
explain you to convert date into long, I use in built function in it.

import java.util.Calendar;
import java.util.Date;

public class test {

        public static void main(String[] args) {
                
                Date dt=new Date(Long.valueOf(1390973400983L));
                System.out.println(dt.toString());
                
                Calendar cal=Calendar.getInstance();
                cal.set(2014, Calendar.JANUARY, 29, 11, 00, 0);
                
                System.out.println(cal.getTimeInMillis());
                System.out.println();
                
        }
}

Method Overloading In java

In a class have multiple method by same name but have different parameter, it is knows as method Overloading.

While Talking about method, it is important to know the different between two terms parameter and argument.

Parameter is a variable defined be a method that receives value when the method is called. parameter are always local to the method they dont have scope outside the method

While argument is a value that is passed to a method when it called.

package sumadding;

public class methodload {

void sum(int a, int b) {

System.out.println("Sum of two number interger number " + (a+b));
                                   }
       void sum (float a, float b)
       {
     
      System.out.println("Sum of two number interger number " + (a+b));
       }
       void sum(double d, double e) {
          {
         
          System.out.println("Sum of two number interger number " + (d+e));
          }
         
    }
     
public static void main(String[] args) {

methodload d = new methodload();
d.sum(3,8);
d.sum(4.7,6.5);
d.sum(4,98);

}

}

Sum of two Number in Java when you enter through key board

 package sumadding;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.jar.Attributes.Name;

public class sumoftwonumber {
public static void main(String[] args) throws IOException {

InputStreamReader a = new InputStreamReader(System.in);
BufferedReader br = new BufferedReader(a);

System.out.println(" ------Enter First Number ------: ");
String frist= br.readLine();
int p = Integer.parseInt(frist);

System.out.println("-------Enter Second Number--------: ");
String second= br.readLine();
int q = Integer.parseInt(second);

int c = p+q;

System.out.println("-- Sum of two Number --: " + c);

}
}

In above program InputStreamReader and BufferedReader
inputstream- This is actually read from the keyboard and store in array list.
BufferReader read the next byte of data from the  Inputstream reader.

In above Code, Frist I take input from the keyboard, user enter value from keyboard that value convert into integer,
I used Integer parsing for convert value from string to integer
same way it take second value from keyboard and store in string, using parse int I convert string into integer and after that i do addition of value and print on java console



Swapping of 2 Variable without use of third in Java

Swapping of Two variable with out using third variable, this question is asked so many times in interview,

Concept and login behind this is very simple

1) Take two variable and assign value to them
2) Add value of both variable
3) Minus value of one variable from above added variable value

Below is the code of swap variable -:

public class swapp {

static int x =10;
static int y= 20;

public static void main(String[] args)
          {
System.out.println("Value of X Before swap :-" + x );
System.out.println("Value of Y Before swap :-" + y );
x=x+y;
-- Swapping of variable logic
y=x-y;
x=x-y;
System.out.println("Value of X after swap :" + x );
System.out.println("Value of Y after swap :" + y );
}


                         }

Drop, Truncate and Delete Query for DB

Delete - Delete command is used to Remove or delete the data from the Database, Delete command delete the row from table of Database, where cause in sql and mysql  delete command is optional, it identify the row in table which we want to delete, no where cause delete all the data from the table
After Performing delete Operation you need to commit or Rollback the transaction to change the permanent or to undo, this operation will cause all the delete trigger in the table

"select count(*) from user_master"

count
-----------------------------------------
  14

"delete from user_master where name='xyz' "

3 row deleted.
----------------------------------------------
select count(*) from user_master

count
------------------------------------------
11

if you want to delete all the data from the table then execute below query

delete from user_master;

=======================================================================

Truncate  : Truncate command is used to delete all the row from the table, once you truncate then that operation can not rollback. Truncate is Faster



Truncate table tablename  - syntax
truncate table user_master;
-------------------------------------------------
table truncate
------------------------------------------
select * from user_master;
--------------------------------------
0 row
======================================================================

Drop: Drop remove the table from the Database, all the tables, index and privileges will also be removed, this operation cannot roll back. be carefully while using this command.


Syntax - Drop table tablename

drop table user_master;

Drop and Truncate are DDL(Data Definition Language) command, where as DELETE is DML( Data manipulation language). Delete command operation can be roll back(undone) while Drop and Truncate Operation cannot be rolled back.









Connection String for MYSQL and MSSQL database, In hibernate file

Mysql and Mssql Database is Different and structure is also different, if you want to connect the mysql and mssql DB with you application through hibernate then you have to enter below code in your hibernate file

both database have diffferent port number and different dialect if you enter replace mysql dialect  with mssql dialect then your code do not run

MySql:

MSsql:

if Database in your local system then you can write 127.0.0.1 or localhost with port number,
but if Database in other machine and that machine with in the Network then you have enter ipaddress of that machine with port number


How to open in MySql through Command prompt in windows system

Mysql is a Database and it is open source( free for all), Generally Mysql is on linux machine but you can also install & access Mysql in windows system.
MySQL is a popular choice of database for use in web applications, syntax of Mysql and Mssql is little bit different but nows a days use of Mysql is more because it is free.

For windows system you have to install mysql in your machine, once it install successfully the open CMD in your system. before this you have to start he mysql services in your system or if you have Wamp server in your system then you have to start the wamp server

C:\> 
Go to location where mysql is install Eg : C:\wamp\bin\mysql\mysql5.5.24\bin>
C:\> cd wamp\bin\mysql\mysql5.5.24\bin
C:\wamp\bin\mysql\mysql5.5.24\bin>
Enter the below Command in cmd then press enter key
mysql -u root -p

In above u stands for username and p stands for password, in my machine i have root user that I enter root you can enter other username also

C:\wamp\bin\mysql\mysql5.5.24\bin> mysql -u root -p



after if you write show Databases; command then it show you all database restore in the machine or list of database
mysql> SHOW DATABASES;
If you want to exit for the mysql then you have to write below command
mysql> exit



Swap Of two Variable without use of Third Variable

Swapping of Two variable with out using third variable, this question is asked so many times in interview,

Concept and login behind this is very simple

1) Take two variable and assign value to them
2) Add value of both variable
3) Minus value of one variable from above added variable value

Below is the code of swap variable -:

public class swap {

static int x =10;
static int y= 20;

public static void main(String[] args)
          {

System.out.println("Value of X Before swap :-" + x );

System.out.println("Value of Y Before swap :-" + y );
x=x+y;
-- Swapping of variable logic
y=x-y;
x=x-y;

System.out.println("Value of X after swap :" + x );

System.out.println("Value of Y after swap :" + y );

}


                         }


OUTPUT :

X=20
Y=10

How to merge data of two column into Single one in SQL ?

In SQL if you have one table which More than two Fields and if you want to merge data of Two or More then two fields then follow the below steps.

Select  column name from  table name
Union
select column name 1 from table name




Select Lastname from employee
union
select Username from employee

Data after execution of above query


above table show concatenation of column in to one, I take lastname and username column and merge into a single column which is show above.



How to Open Chrome Browser using Selenium webdriver ?

Selenium Web driver is used for Automation testing and it is a open source tool, you can create automation script for your website and run it through web driver frame work

Create a java project





once the java project is created you have to download the selenium standalone jar file here image is displayed below

  • Once the file is download 
  • Extract that file on your machine
  • Import the jar file in your project
  • Right clicked on your project
  • Clicked on built path
  • Clicked on the configure built path



  • Add "all the jar " file in your project
write below code in your class file and check



import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;

public class Enter_class_name {

public static void main(String[] args) {
System.setProperty("webdriver.chrome.driver", "E:/chromedriver.exe");
WebDriver driver = new ChromeDriver();
driver.get("http://www.google.com");
}
}

you have to download chrome driver file from below location
http://chromedriver.storage.googleapis.com/index.html

Run this code with java application and check your bowser is open and in which Google.com site is open















How to Restart services of MYSQL Database in Linux through Terminal


Some time Mysql is not Working and we try to login into it and it gave us error or it do not responded in that case you have to Restart the services of mysql.

Below is the following error ?
  1. How do I get mysql prompt in linux terminal?
  2. How I start the mysql server from linux terminal?
  3. How do I get mysql prompt in linux terminal?
  4. How do I login to mysql server from linux terminal?
  5. How do I solve following error?

If you want to Prompt in linux terminal then you have to open terminal in linux and have enter below command

>> mysql -u root - p 
After this you have to enter password, after entered corrected password you are able to login.

-----------------------------------------------------------------------------------------------------------------
  1. How I stop the mysql server from linux terminal ?
If you want to start the mysql server then you have to fire below query 

>> Sudo /etc/init.d/mysql start

If you want to restart the mysql  services then you have to fire below query 

>> Sudo /etc/init.d/mysql restart

If you want to stop the mysql  services then you have to fire below query 

>> Sudo /etc/init.d/mysql stop

mysql is free or it is open source, so many industries used it, some time testing website on mysql and site is not open on your browser then there is mysql connection is problem, for that you have to restart services of my sql. 


How to run Selenium WebDriver test cases in Chrome?

Selenium Webdriver is an automation testing tools, now a days it is very user full for testing, it is an open source tool
In market we have Selenium Webdriver and Selenium RC, Different between them is for webdriver we do not have to start the server but in RC we have to start the server before running our code, and selenium RC support old version of browser

Steps :
1) You need to download the executable driver file from here  : Chrome Driver
2) After download file take path of file and paste in code which I wrote below.
3) Open your Eclipse and create any project
              how to create project In eclipse is describe here Eclipse

public class Chrome {

  public static void main(String[] args) {

        System.setProperty("webdriver.chrome.driver", "E://chromedriver.exe");
        WebDriver driver = new ChromeDriver();              
        driver.get("http://www.google.com");

    }
}
with the help of this code you can open the FF browser and google website in new tab.
Role of set property is very important it set property of browser so that code can executed
In above code we create a object of Webdriver and with the help of object we open the browser and URL in the browse.












How to Create project in Ecplise IDE ?

Eclipse is a software which is used to create application by writing and code and execute them, eclipse provide so many Short cut in it. Below is the snapshot which give you how to create project in eclipse

Eclipse provide facility to write the code and run it also you can debug the same and identity where you face issue . Eclipse have in built Glass fish server and eclipse easily integrated with android and other application, you can write android code and run the same code in the eclipse.



  • Open Eclipse in your system 
  • Clicked on New > java Project 



  • Check a pop-up is open
  • Enter Project in that pop-up
  • Clicked on Finished button



  • Check java project is created


  • Right Clicked on the Project name
  • Click on the new, check drop down is open
  • Clicked on the package


  • Enter the package name
  • Clicked on the Finished button



  • Check package is created
  • Right clicked on the package name
  • Clicked on the new
  • Check drop down is open
  • click on the class link






  • Enter class name 
  • clicked on the finished button
  • Check a project is created






How to do Manual Testing ?

Testing is a process with intend to found issues in application or Software.

Manual testing is the oldest and most rigorous type of software testing. Manual testing requires/need a tester to perform manual test operations on the test software without the help of Test automation(Testing tools). Manual testing is a laborious activity that requires the tester to possess a certain set of qualities; to be patient, observant, speculative, creative, innovative, open-minded, resourceful and skillful.

 manual testing can be difficult to perform on large software applications or applications having very large data set coverage because it is time consuming and you can not test large project fully with manual without help of automation. This drawback is compensated for by using manual black-box testing techniques including equivalence partitioning and boundary value analysis. Using which, the vast data set specifications can be divided and converted into a more manageable and achievable set of test suites.

 In simple Language we can say that - Testing through eyes to found any issue or bug in the application or website, irrespective of other thing and it does not matter whether issue small or large

Good example of Testing : when a girls saw a boy, she can see/scan his body from top to Bottom and tell then about that boy as same way when a boy saw a girl he can scan him from top to bottom and told some comment or in technical language some issue.

Basic Fund of testing is to find issue or break the site, overall we have to provide Quality of Product

Different b/w verification and assertion in selenium ide?




I see two types of check with Selenium – verification and assertion, what’s the difference between tow?

       A verification check lets test execution continue even in the wake of failure with check, while assertion stops the test execution. Consider an example of checking text, Header on a page, you may like to use verification point and let test execution continue even if text is not present. But for a login page, you would like to add assertion for presence of text box login as it does not make sense continuing with test execution if login text box is not present

In simple language, when a test case is executed by Selenium ide and Verify command is come then test is do not stoped by selenium, if some text is not verify or presence in web page then selenium ide execute the next step but in assert case is different, when a test case is execute and assert command come for execution and assert text is not presence then selenium ide stop the execution of that test and other step will not executed.
Powered by Blogger.