In this post, we will discuss reducing the number of parameters even further to more granular level after the introduction of Page Object Model in our code, please read my previous post for more details on POM
Here is the complete video for the above discussion
Here is the complete code
Set Methods for controls like Textbox, Button, DropDownList box.
//Enter text in the Textbox
public static void EnterText(IWebElement element,string value)
{
PropertiesCollection.driver.FindElement(By.Id(element)).SendKeys(value);
}
//Click into a button, Checkbox, option etc
public static void Click(IWebElement element)
{
PropertiesCollection.driver.FindElement(By.Name(element)).Click();
}
//Selecting a drop down control
public static void SelectDropDown(IWebElement element, string value)
{
new SelectElement(PropertiesCollection.driver.FindElement(By.Name(element))).SelectByText(value);
}
Get Methods for controls like Textbox and DropDownList box
public static string GetText(IWebElement element)
{
return PropertiesCollection.driver.FindElement(By.Name(element)).GetAttribute("value");
}
public static string GetTextFromDDL(IWebElement element)
{
return new SelectElement(PropertiesCollection.driver.FindElement(By.Name(element))).AllSelectedOptions.SingleOrDefault().Text;
}
Thanks for watching the video and reading the post!!
Please leave your comments and let me know if there is anything need to be improved in the post!!!
Thanks,
Karthik KK