Monday, October 14, 2013

Excel : Insert Combo Box







Inserting Combo Box in Excel



1.      Select the cell where you want to put the combo box .
2.      Goto  Tool Bar>Data>Data Validations >In Allow ,select “List”


3.      In Data Validation> Source field  , Click on the icon located at the end  and goto the column where the data is present and select all the data you want to listed inside the como box.
4.      Click on Ok .


Friday, October 4, 2013

Selenium : Properties File [Updated]

Selenium : Properties File [Updated]

 

Create a  properties file
  1. Open Eclipse
  2. Inside a package> Rt Clk> New >File 
  3. File Name = OR.properties
  4. Click OK
 [ Inside OR.properties  ]
----------------------------------------------------------------------------
Google.search_button=//button[@id='gbqfba']
youtube_link=//a[@id='gb_36']/span[2]


 --------------------------------------------------------------------------

 // [Main Function ]


import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Dictionary;
import java.util.Hashtable;
import java.util.Properties;
import java.util.ResourceBundle;
import javax.swing.JOptionPane;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;


public class Sample1
{
    public static void main(String[] args) throws IOException  
    {
      
        Properties oProp=new Properties();    //create properties object
        FileInputStream oFilestream= new FileInputStream("C:\\Selenium\\Sample_Workspace\\Sample\\src\\OR.properties");                                 //Open properties file using Fileinputstream
        oProp.load(oFilestream);                    //Load FileInputStream into properties object
      
        FirefoxDriver oDriver=new FirefoxDriver();
        oDriver.get("http://google.com");
      
        WebElement oSearch=oDriver.findElementByXPath(oProp.getProperty("Google.search_button"));

//Access properties 
 
        Misc_Operations.highlightElement(oDriver, oSearch);
          
    }
  
}

Tuesday, October 1, 2013

Java : Small GUI application Frame,Panel and Button Click (Ver 2.0)

Java : Small GUI application Frame,Panel and Button Click (Ver 2.0) 

  // Identifies button name though the action performed
// Use JDialog instead of JFrame for thread to pause until an event


package start;
import java.awt.*;//ActionListener;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.*;

public class Test
{
    public static void main(String[] args)
    {
        GUI Test1=new GUI();
        JFrame oFrame=Test1.Create_Panel();
    }
}

//http://docs.oracle.com/javase/tutorial/uiswing/components/frame.html
  class GUI extends JFrame implements ActionListener  {
    JPanel Panel;
    JFrame Frame;
    JButton Button;
    JLabel Label;
  
    public JFrame Create_Panel()   // Return type = JFrame
    {          
        this.Frame=new JFrame("FrameDemo");                    //Frame
        this.Panel=new JPanel();                            //Panel
        this.Button=new JButton("Hi");                        //Button

       
        Button.addActionListener(this);
        Button.setSize(20, 30);
        Panel.setSize(20, 30);
        Frame.setSize(100, 100);
               
        Frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);    //Optional: What happens when the frame closes?
        Panel.add(Button);                                        //Panel<-Button
        Frame.add(Panel);                                        //Frame<-Panel
                                        //Frame<-Panel<-Button
        Frame.setVisible(true);                                    //Show it.
        return Frame;
    }
               
    public void actionPerformed(ActionEvent e)
    {  

         String buttonText = ((JButton) e.getSource()).getText();
        System.out.print(buttonText);
        JOptionPane.showMessageDialog(null, "Button Pressed2");
    }
  
}