public IUIWebElement GetUIElementById(string controlName) { IWebElement toReturn = null; Exception e = null; System.Threading.Thread.Sleep(2000); Controls.ForEach(x => { if (x[controlName] != null) { for (var i = 0; i < 10; i = i + 1) { try { LogProvider.DefaultLogger.Log("Looking for: " + controlName); toReturn = Context.FindElement(By.Id(x[controlName])); if (toReturn != null) { LogProvider.DefaultLogger.Log("Got " + controlName); break; } } catch (Exception e1) { LogProvider.DefaultLogger.Log("Could not get " + controlName); e = e1; } } } }); if (toReturn == null) return null; var element = new UIElement(toReturn, controlName); element.Driver = Driver; element.Context = element; element.Controls = Controls; System.Threading.Thread.Sleep(2000); return element; }
public IUIWebElement MatchByPartialLinkText(string textToMatch) { IWebElement toReturn = null; Exception e = null; System.Threading.Thread.Sleep(2000); try { LogProvider.DefaultLogger.Log("Looking for: " + textToMatch); toReturn = Context.FindElement(By.PartialLinkText(textToMatch)); if (toReturn != null) { LogProvider.DefaultLogger.Log("Got " + textToMatch); } } catch (Exception e1) { LogProvider.DefaultLogger.Log("Could not get " + textToMatch); e = e1; } if (toReturn == null) return null; var element = new UIElement(toReturn, textToMatch); element.Driver = Driver; element.Context = element; element.Controls = Controls; System.Threading.Thread.Sleep(2000); return element; }
public List<IUIWebElement> GetUIElements(string controlName) { var list = new List<IWebElement>(); Exception e = null; System.Threading.Thread.Sleep(1000); Controls.ForEach(x => { if (x[controlName] != null) { for (var i = 0; i < 10; i = i + 1) { try { LogProvider.DefaultLogger.Log("Trying to get " + controlName); list = Context.FindElements(By.CssSelector(x[controlName])).ToList(); if (list != null) { LogProvider.DefaultLogger.Log("Got " + controlName); break; } } catch (Exception e1) { LogProvider.DefaultLogger.Log("Could not get " + controlName); e = e1; } } } }); // create an empty list of IUIWebElements (eg 'resultList') // iterate over the list of IWebElements ('list') // for each element of 'list', create an element of IUIWebElement and add to resultList // return resultList if (list == null) return null; var resultList = new List<IUIWebElement>(); for (var i = 0; i < list.Count; i++) { var element = new UIElement(list[i], controlName); element.Driver = Driver; element.Context = element; element.Controls = Controls; resultList.Add(element); } System.Threading.Thread.Sleep(1000); return resultList; }