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");


Author: Pavandeep Puddupakkam on July 12, 2011
Category: WebDriver
Tags: , , , ,
Google Webdriver Forum -The Online Community for Google Webdriver and Selenium RC Users and Professionals

Leave a Reply

Last articles