Wikipedia

Search results

Monday, 21 October 2013

Java Concepts

 java important to selenium because it is a platform language.

Java is guaranteed to be Write Once, Run Anywhere.

Java is:
  • Object Oriented: In Java, everything is an Object. Java can be easily extended since it is based on the Object model.
  • Platform independent: Unlike many other programming languages including C and C++, when Java is compiled, it is not compiled into platform specific machine, rather into platform independent byte code. This byte code is distributed over the web and interpreted by virtual Machine (JVM) on whichever platform it is being run.
  • Simple:Java is designed to be easy to learn. If you understand the basic concept of OOP Java would be easy to master.
  • Secure: With Java's secure feature it enables to develop virus-free, tamper-free systems. Authentication techniques are based on public-key encryption
  • Robust:Java makes an effort to eliminate error prone situations by emphasizing mainly on compile time error checking and runtime checking.
  • Multithreaded: With Java's multithreaded feature it is possible to write programs that can do many tasks simultaneously. This design feature allows developers to construct smoothly running interactive applications.
  • Interpreted:Java byte code is translated on the fly to native machine instructions and is not stored anywhere. The development process is more rapid and analytical since the linking is an incremental and light weight process.
  • High Performance: With the use of Just-In-Time compilers, Java enables high performance.
  • Distributed:Java is designed for the distributed environment of the internet.
  • Dynamic: Java programs can carry extensive amount of run-time information that can be used to verify and resolve accesses to objects on run-time.

    Simple Java Program

    public class MyFirstJavaProgram {
    
        public static void main(String []args) {
           System.out.println("Hello World");
     
        }
    } 

    //
     System.out.println helps to output will be printed in the next line.
     
 Java Basics:

In Java program it can be defined as a collection of objects that communicate via invoking each others methods. Lets look into what is Class,Object,Methods and instance variables.

  • Object - Objects have states and behaviors . An object is an instance of a class.
  • Class - A class can be defined as a template/ blue print that describes the behaviors/states that object of its type support.
  • Methods/Functions - A method is basically a behavior. A class can contain many methods. It is in methods where the logic's are written, data is manipulated and all the actions are executed.
  • Instance Variables - Each object has its unique set of instance variables. An object's state is created by the values assigned to these instance variables.

    Java Data Types:

    Variables are nothing but reserved memory locations to store values. This means that when you create a variable you reserve some space in memory.
     
    Based on the data type of a variable, the operating system allocates memory and decides what can be stored in the reserved memory. Therefore, by assigning different data types to variables, you can store integers, decimals, or characters in these variables.

    Let us now look into detail about the  primitive data types.

    1)int:
    Int data type is a 32-bit signed two's complement integer.
     Ex:int i = 100;
    The default value is 0.
    2) Long:
    Long data type is a 64-bit signed two's complement integer. 
    Ex: long x = 100000L
    Default value is 0L.
    3)double:
    double data type is a double-precision 64-bit
    This data type is generally used as the default data type for decimal values  and integers
    Ex:double d = 154.1
    4)Char:
     char data type is a single 16-bit Unicode character.
    Char data type is used to store any character
    Ex: char C ='b';
    5)boolean:
    There are only two possible values: true and false. 
    Default value is false.
    specially used in If statement
    Ex:boolean = false;
    5)String:
     Ex:String str = "I am writing java program";

     
      Next post we will Discuss about String Class

Installing Eclipse

Installing Eclipse is relatively easy, but does involve a few steps and software from at least two different sources. Eclipse is a Java-based application and, as such, requires a Java run time environment (JRE) in order to run. 

1)Install a JVM
Regardless of your operating system, you will need to install some Java virtual machine (JVM). You may either install a Java Runtime Environment (JRE), or a Java Development Kit (JDK), depending on what you want to do with Eclipse. If you intend to use Eclipse for Java development, then you should install a JDK (the JDK includes--among other useful things--the source code for the standard Java libraries). If you aren't planning to use Eclipse for Java development and want to save some disk space, install a JRE.  

2)Eclipse Download

Download Eclipse from the Eclipse Download Page 

Make sure download Eclipse IDE for Java EE Developers Eclipse IDE for Java EE Developers, 247 MB

The download will be delivered as a compressed (i.e. a ".zip", or ".tar.gz") file. Decompress this file into the directory of your choice (e.g. "c:\Program Files\Eclipse" on Windows). You can optionally create a shortcut of the executable file ("eclipse.exe" on Windows).  

Click on Eclipse.exe and create your Workspace 
  
File->New->Project->Java Project

Start writing your Java code !!





Learn SeleniumWebdriver

Learning selenium isn't all that easy especially if you have been using either QTP or any other tool that uses simple scripting.but i have simple and strategic set of things to learn and If you go about this then you are ready for any god damn Selenium Code!

Java Introduction and Concepts
  • First Java program
  • Concept of class file
  • Platform independence
  • Data types in Java
  • String class
  • If statements
  • While Loop
  • For Loops
  • Single/Two Dimensional Arrays
  • Function Input Parameters
  • Function Return Types
OOPS Concept's 
  • Local/ Global Variables
  • Static and Non-Static Variables
  • Static and Non-Static Functions
  • Objects in Java
  • Call by reference and Value
  • Constructors
  • Inheritance
  • Interface
  • Overloading and Overriding Functions
More Java
  • Packages
  • Access modifiers - Public, Private, Default, Protected
  • Exception handling with try catch block
  • Throw able Class
  • Final and Finally
  • Throw and Throws
  • Collections API
  • Array List Class
  • Hash Table Class
  • Reflection API 
That's Enough Java already
  • String class and functions
  • Reading/Writing Text Files
  • Reading Properties File in Java
  • Concept of jar file
  • POI API in java
  • Reading/Writing Microsoft XLS Files
  • Log4j API for Logging
Junit or TestNG?
  • Configuring Junit 4 in Project/Eclipse
  • Junit 4 annotation
  • Running Test in Junit
  • Skipping Tests
  • Parametrize Tests
  • Using Assertions
  • Reporting Errors / Error Collector
  • Batch Running - Custom Runners
  • OR
  • TestNg annotations
  • Running a Test in TestNg
  • Batch Running of tests in TestNg
  • Skipping Tests
  • parametrize Tests - Data Provider
  • Assertions/Reporting Errors
  • TestNg Reports
  • XSLT report generation generation using TestNg and Ant
  • Building a BAT file to run tests using ANT
  • What is Ant
  • Downloading and configuring Ant
  • Build.xml configuration
  • HTML Report generation using Ant
Selenium WebDriver Demystified
  •  XPATHS and installing firebug to get XPATHS
  •  Wait Commands
  •  Verification and Assertions
  •  JavaScript
  •  Echo, StoreEval and StoredVars Demystified
  •  Reading XML from JavaScript using DOM.
  •  Handling JavaScript Alerts
  •  Configuring in eclipse
  •  Drivers for Firefox, IE, chrome, Iphone, Android etc
  •  Selenium RC and WebDriver
  •  Firefox profile
  •  Close and Quit -Difference
  •  Importing webdriver documentation in eclipse
  •  WebDriver Class
  •  Proxy settings with webdriver
  •  HTMLUnit driver
  •  Firepath and firebug Add-ons 
  •  Inspecting elements in Mozilla, Chrome and IE
  •  WebDriver Interface
  •  WebElement Interface
  •  Identifying WebElements using id, name, class 
  •  Xpaths 
  •  CssSelectors as compared to Xpaths
  •  Class attribute
Used to Selenium?
  •  Handling Dynamic objects/ids on the page
  •  Working with different browsers without changing code
  •  Managing Input fields, Buttons and creating custom xpaths
  •  Managing/Identifying Links with xpaths/css selectors
  •  Extracting More than one object from a page
  •  Extracting all links of a page/Bulk extraction of objects
  •  Extracting Objects from a specific area of a web page
  •  Finding response Headers/ response code
  •  Finding whether object is present on page or not
  •  Handling drop down list
  •  Select Class in Selenium API
  •  Managing radio buttons and Checkboxes
  •  Hidden components
  •  isDisplayed function
  •  Taking Screenshots of the web pages
  •  Implicit and Explicit waits
  •  PageLoadTimeout Property
  •  WebDriverWait Class
  •  WebDriver.Timeout Interface
  •  ExpectedCondition interface and Expected Conditions class
  •  WaitUntil Condition
  •  Fluent Wait
  •  Managing Ajax based components
  •  Concepts of Set Interface in Java
  •  Window Handles
  •  Managing tabbed windows in IE, Chrome and Mozilla
  •  Managing popups in IE, Chrome and Mozilla
  •  Closing windows
  •  Default Popups
  •  Testing https websites / Managing certificate errors in https websites in IE, Chrome and Mozilla
  •  Dynamic WebTable Handling
  •  Attaching files with Selenium
  •  Mouse movement with Selenium- Mouse Interface
  •  Handling Ajax Auto suggests
  •  Handling Frames in Web Page
  •  Handling cookies
  •  Simulating front and back buton click on Browser using selenium
  •  Assigning Firefox profile parameters
  •  Listeners- Using WebDriverEventListener
  •  Finding Coordinates of a Web Object
  •  Actions class in Webdriver
  •  Drag, drop, native events