How to login with Citibank using selenium

132 views
Skip to first unread message

Smita Chopadekar

unread,
Feb 6, 2016, 5:27:45 AM2/6/16
to Selenium Users
Hi,

I want to login with citibank using automation . i am not able to enter my username , see below Code



import java.util.Set;

import org.openqa.selenium.By;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.interactions.Actions;

public class Citi {

    public static void main(String[] args) {
        // TODO Auto-generated method stub
       

        WebDriver driver = new FirefoxDriver();
           driver.get("https://www.online.citibank.co.in/");
           String myWindowHandle = driver.getWindowHandle();
           driver.findElement(By.xpath("//*[@id='container']/div[2]/div[2]/div/div[1]/div[1]/p[2]/a[1]/img")).click();
        // sleep for a bit
           try {
            Thread.sleep(3000L);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }   
         
            Set<String> handles = driver.getWindowHandles() ;
         
            for(String winHandle : driver.getWindowHandles()){
                     if(myWindowHandle.equalsIgnoreCase(winHandle))
                        continue;
                     driver.switchTo().window(winHandle);
                 }   
                 String shipperURL =  driver.getCurrentUrl();
                 
                 driver.switchTo().window(myWindowHandle);
    }
    public static void Login(WebDriver driver){
        WebElement e = driver.findElement(By.xpath("//*[@id='User_Id']"));
        e.sendKeys("dfdfdf");
               
   
   
Need Solution pls

do i need to use phantomjs in this case
}
}

Nikhil Srivastava

unread,
Feb 6, 2016, 12:47:59 PM2/6/16
to seleniu...@googlegroups.com
Hi Smita,

Can you please call login function from Main method?   

Update below piece of code:-

for (String winHandle : handles) {
if (myWindowHandle.equalsIgnoreCase(winHandle))
continue;
driver.switchTo().window(winHandle);
}
String shipperURL = driver.getCurrentUrl();

// driver.switchTo().window(myWindowHandle);

Citi.Login(driver);
}

public static void Login(WebDriver driver) {
WebElement e = driver.findElement(By.xpath("//*[@id='User_Id']"));
e.clear();
e.sendKeys("ababc");

}
}

Thanks,
Nikhil

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-user...@googlegroups.com.
To post to this group, send email to seleniu...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/f546d5cd-a587-469c-b26f-9ab834dff878%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages