selenium-webdriver Interaction With Web Element C#


Example

Clearing the Content of element(Generally Text Box)

interactionWebElement.Clear();  

Entering data to element (Generally Text Box)

interactionWebElement.SendKeys("Text");

Storing the value of the element.

string valueinTextBox = interactionWebElement.GetAttribute("value");

Storing Text of element.

string textOfElement = interactionWebElement.Text; 

Clicking on an Element

interactionWebElement.Click();

Submitting a Form

interactionWebElement.Submit(); 

Identifing the visibility of an element on the page

bool isDisplayed=interactionWebElement.Displayed; 

Identifing the state of an element on the page

bool isEnabled = interactionWebElement.Enabled; 

bool isSelected=interactionWebElement.Selected; 

Locating child element of interactionWebElement

IWebElement childElement = interactionWebElement.FindElement(By.Id("childElementId")); 

Locating child elements of interactionWebElement

Ilist<IWebElement> childElements = interactionWebElement.FindElements(By.TagName("childElementsTagName"));