public static IWebElement GetElement(this ISearchContext context, By by, int timeOut = 20) { IWebElement element = null; try { var wait = new DefaultWait <ISearchContext>(context) { Timeout = TimeSpan.FromSeconds(timeOut) }; return(wait.Until((ctx) => { WaitHelpers.WaitFor(() => ctx.FindElements(by).Count != 0, "Not Able to find element! ELement might not be present"); element = ctx.FindElement(by); if (!element.Displayed) { return null; } return element; })); } catch (NoSuchElementException ex) { Console.WriteLine("OOPs!! Unable to find the mentioned element! Exception: {0}", ex.Message); } return(element); }
private static void Main(string[] args) { ServiceCheck serviceCheck = new ServiceCheck(); ApplicationHelpers applicationHelpers = new ApplicationHelpers(); MeatMaster2Functions functions = new MeatMaster2Functions(); Functions.logger.LogInfo("Program is starting."); serviceCheck.WaitForServiceToStart(ServiceCheck.ServiceManagerServiceName, 10); WaitHelpers.WaitFor(() => applicationHelpers.ProcessIsRunning(MeatMaster2UiItems.Mm2ProcessName), TimeSpan.FromMinutes(15)); DatabaseHelpers.DeleteLastDataMaintenanceDate(); functions.CancelStartup(); functions.CloseDown(false); applicationHelpers.RestartWindows(); }
public static void EnterText(this IWebElement element, string text) { WaitHelpers.WaitFor(() => element.Displayed && element.Enabled, "Not Able to find element! ELement might not be present"); element.SendKeys(text); }