2

I am not able to select data from the calendar because it is not having the id's to select.

below is my HTML code,

enter image description here

enter image description here

The Code I tried is

 DateDOB = By.xpath("//*[@id='dob']")
strDateDOB="12/12/2020"
driver.findElement(DateDOB).sendKeys(strDateDOB);

but unable to select the date

Url to the application :

http://demo.guru99.com/V4/

username : mgr123 Password : mgr!23

Click on the New Account from the Left Pane to select the above discussed desired page.

Can any one please help in selecting the date?

1 Answer 1

1

DOB has the id. sendKeys works. Don't use XPATH when ID is present.

I tried the following code and it is entering DOB value:

@Test
public void tst1() {
    WebDriver driver = new FirefoxDriver();
    driver.get("http://demo.guru99.com/V4/");
    driver.findElement(By.name("uid")).sendKeys("mgr123");
    driver.findElement(By.name("password")).sendKeys("mgr!23");
    driver.findElement(By.name("btnLogin")).click();
    driver.findElement(By.linkText("New Customer")).click();
    driver.findElement(By.id("dob")).sendKeys("12/12/2018");
    sleep(5000);

}
Sign up to request clarification or add additional context in comments.

3 Comments

Hi Naveen, Thanks for the reply, but it is not working for me :( iam using webdriver of 2.3.0 & java version "1.8.0_121" , Firefox 57.0 version.
Hi Naveen, I was able to solve by javaScript Executor method. WebElement select = driver.findElement(By.id("dob")); JavascriptExecutor js = (JavascriptExecutor)driver; js.executeScript("arguments[0].type = arguments[1]", select, "text"); driver.findElement(By.id("dob")).sendKeys(strDateDOB);
2.3.0 has support till Firefox 47 version. for later versions, gecko driver needs to be used. also, upgrade selenium to the latest version (>3 version). I am not sure they are still supporting FirefoxDriver in latest gecko driver and Firefox browsers.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.