public static bool SetText(By Locator, string text) { // element = GenericHelper.GetElement(Locator); // element.SendKeys(text); bool isTextEntered = false; try { if (Locator != null) { // LoginUtil.ScrollIntoView(Locator); ObjectRepository.webelement = GenericHelper.GetElement(Locator); ObjectRepository.webelement.SendKeys(text); logs.Info("Text set : " + text); isTextEntered = true; } if (!isTextEntered) { //LogException("Object does not exist and failed to set text to textbox", String.Empty, logMessageOnException); } } catch (Exception e) { // LogException("Failed to set text to textbox", e.ToString(), logMessageOnException); } return(isTextEntered); }
public static void SelectListByIndex(By Locator, int index) { element = GenericHelper.GetElement(Locator); SelectElement select = new SelectElement(element); select.SelectByIndex(index); logs.Info("Selected the Item index: " + index); }
public static void ClickButton(By Locator) { try { buttonElement = GenericHelper.GetElement(Locator); buttonElement.Click(); logs.Info("Button clicked : " + Locator); } catch (Exception e) { logs.Error(e.StackTrace); GenericHelper.TakeScreenshotForMePlease(); throw; } }
public static IList <string> GetAllItem(By Locator) { try { element = GenericHelper.GetElement(Locator); SelectElement select = new SelectElement(element); return(select.Options.Select((x) => x.Text).ToList());//Linq expression } } catch (Exception e) { logs.Error(e.StackTrace); GenericHelper.TakeScreenshotForMePlease(); throw; } }
public static void SelectListItemByname(By Locator, string item) { try { element = GenericHelper.GetElement(Locator); SelectElement select = new SelectElement(element); select.SelectByValue(item); logs.Info("Selected the Item: " + item); } catch (Exception e) { logs.Error(e.StackTrace); GenericHelper.TakeScreenshotForMePlease(); throw; } }
public static void ClearTextFromTextBox(By Locator) { //element = GenericHelper.GetElement(Locator); //element.Clear(); try { if (Locator != null) { //LoginUtil.ScrollIntoView(Locator); ObjectRepository.webelement = GenericHelper.GetElement(Locator); ObjectRepository.webelement.Clear(); logs.Info("Text Cleared from locator: " + Locator); } } catch (Exception e) { // LogException("Failed to set text to textbox", e.ToString(), logMessageOnException); } }
public static string GetButtonText(By Locator) { try { buttonElement = GenericHelper.GetElement(Locator); if (buttonElement.GetAttribute("value") == null) { return(string.Empty); } logs.Info("Button Text : " + Locator); } catch (Exception e) { logs.Error(e.StackTrace); GenericHelper.TakeScreenshotForMePlease(); throw; } return(buttonElement.GetAttribute("value")); }
public static bool IsButtonEnabled(By Locator) { buttonElement = GenericHelper.GetElement(Locator); return(buttonElement.Enabled); }