Selenium Java to get the current date and time using sendKeys
KW.java
import org.openqa.selenium.By;
import org.openqa.selenium.Keys;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;

class KW
{
    public static void main(String[] args) 
    {   
        System.setProperty("webdriver.chrome.driver", "/home/kodingwindow/drivers/chromedriver");
        WebDriver driver = new ChromeDriver();
        
        driver.get("https://www.google.co.in/");
        driver.findElement(By.tagName("textarea")).sendKeys("Current Time In India");
        driver.findElement(By.tagName("textarea")).sendKeys(Keys.ENTER);
    }
}
Output

Advertisement