SendKeys

Overriding the SendKeys Selenium 2 Webdriver 

Here is a function I have written that checks if an element is present and then executes the Type/SendKeys command.

public void type(String xpath, String value)
{ if (driver.FindElement(By.XPath(xpath))!=null)
{
driver.FindElement(By.XPath(xpath)).SendKeys(value);
}
else
{
Console.WriteLine("The element is not found: " + xpath);
}
}

Using the function in the test script.

type("//input[@name='p']", "Selenium Wiki");