Home » Java » java – When I am using SendKeys to send the date in the field and when I am running the script its pasting the date twice in that field-Exceptionshub

java – When I am using SendKeys to send the date in the field and when I am running the script its pasting the date twice in that field-Exceptionshub

Posted by: admin February 25, 2020 Leave a comment

Questions:
        package debut.Ifinca.NewOrder;
        import org.openqa.selenium.By;
        import org.openqa.selenium.WebDriver;
        import org.openqa.selenium.chrome.ChromeDriver;
        import org.openqa.selenium.support.ui.Select;

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

            {       System.setProperty("webdriver.chrome.driver","C:\\Users\\COMPUTER\\Desktop\\chromedriver_win32 (2)\\chromedriver.exe");
                WebDriver driver = new   ChromeDriver();
                driver.get("http://js-server.debutinfotech.com:3093/");

                driver.manage().window().maximize();
 //Here When I am sending this date its getting entered twice in this field.This field has Date picker format.
    driver.findElement(By.xpath(".//input[@id='exporter_delivery_date']")).sendKeys("02/18/2020");
        }
        }
How to&Answers:

Have you tried clearing the field first?

driver.findElement(By.xpath(".//input[@id='exporter_delivery_date']")).clear();
driver.findElement(By.xpath(".//input[@id='exporter_delivery_date']")).sendKeys("02/18/2020");