As shown clearly in the script for this example, to clear what is written in a text area using the Selenium
WebDriver you need to use element.Clear() where element is the text input.
IWebElement query = driver.FindElement(By.Id("searchInput"));
The easiest way to check if an element is present on a web page is to find all the elements matching the element
locator and check that the size of the resulting list is not 0. Selenium doesn't offer any solutions more concise
than this due to the nature of element locating.
WebElements can be located with selenium webdriver using XPaths. These are expressions that identify elements on a page based on certain details, such as, if the element contains a specific attribute or has a specific child node.
To wait until the page is loaded, the easiest way is to use a WebDriverWait to force the driver to wait until an element is visible that you know is only present on the page you are navigating to.You can do this using WebDriverWait.
To locate an element, you need to find the element based on its XPath as you can specify the text the element should contain using "contains(text(), 'YOUR TEXT HERE')".
To return the inner HTML source you need to use the element.GetAttribute("innerHTML") code as shown below.
string output = element.GetAttribute("innerHTML");
String title = (String) js.executeScript("return document.title");