This is to login for HDFC credit card.

import java.util.Iterator;
import java.util.Scanner;
import java.util.concurrent.TimeUnit;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;

public class HdfcBank {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        System.out.println(“give your hdfc credit card userid: “);
        String userid = in.next();
        System.out.println(“give your pass: “);
        String pass = in.next();
        WebDriver driver = new FirefoxDriver();
        driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);
        driver.get(“http://www.hdfcbank.com/”);
        driver.findElement(By.xpath(“//img[@src=’/assets/images/login_butn.png’]”)).click();
        Iterator<String> browser = driver.getWindowHandles().iterator();
        String parent = browser.next();
        String child1 = browser.next();
      
        driver.switchTo().window(child1);
        driver.findElement(By.xpath(“//img[@src=’/assets/images/netbanking_continue_red.gif’]”)).click();
        driver.switchTo().frame(driver.findElement(By.xpath(“//frame[@src=’RSLogin.html’]”)));
        driver.findElement(By.xpath(“//p[strong[text()=’Credit Cardholders’]]//a[text()=’click here’]”)).click();
      
        Iterator<String> browser1 = driver.getWindowHandles().iterator();
        String child2=null;
        while(browser1.hasNext())
        {
             child2 = browser1.next();
        }
        driver.switchTo().window(child2);
        driver.findElement(By.xpath(“//input[@name=’fldLoginUserId’]”)).sendKeys(userid);
        driver.findElement(By.xpath(“//input[@type=’password’]”)).sendKeys(pass);
        driver.findElement(By.xpath(“//img[@alt=’Log In’]”)).click();
    }

}

 

Source: http://selenium-makeiteasy.blogspot.com