Wednesday, June 18, 2014

Login to http://www.makemytrip.com/

Note- Here we need to take care while writing the xpath for password field because that has some hidden html code.

import java.util.concurrent.TimeUnit;

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

public class SuccessLogin{
public static void main(String[] args){

WebDriver driver =new FirefoxDriver();
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
driver.get("http://www.makemytrip.com");
driver.findElement(By.id("login_dropOpenItem")).click();
driver.findElement(By.id("username")).sendKeys("rishi.vg1@gmail.com");
driver.findElement(By.xpath("//input[@id='password_text']")).sendKeys("somepassword");
driver.findElement(By.id("login_btn")).click();
}
}

2 comments:

  1. Sanjay,

    I tried out the above code. Its not sending the sendKeys value into the password field. Can you please verify it once and lemme know.? The xpath used for password field is correct and I tried it with By.id as well. Still it didn't work.

    Thanks,
    Sreedevi

    ReplyDelete
    Replies
    1. Yes Sree, there is some issue like sometime some pop up comes while opening the website. So request you to please try to run the code 2-3 times. Then you will get how it works.

      Delete