/// <summary> /// Check if 'from/to lang' dropbox is not empty. /// </summary> /// <param name="dropBox">IWebElement of dropbox</param> /// <param name="langOptions">Ilist of options of dropbox</param> /// <param name="from">true: 'from language' /// false: 'to language'</param> public bool CheckLangDropboxEmpty(DropboxType type) { IWebElement dropBox = GetLangElement(type); IList <IWebElement> langOptions = GetLangOptions(type); return(langOptions.Count >= 1); }
/// <summary> /// Dropbox 'from/to language'. /// </summary> /// <param name="from">true: from language /// false: to language</param> /// <returns>IWebElement of dropbox</returns> IWebElement GetLangElement(DropboxType type) { if (type == DropboxType.From) { return(driver.FindElement(fromLangLocator)); } else { return(driver.FindElement(toLangLocator)); } }
/// <summary> /// Check if 'from/to language' droppbox contains options 'Русский'/'Английский' respectively. /// </summary> /// <param name="dropBox">IWebElement of dropbox</param> /// <param name="langOptions">Ilist of options of dropbox</param> /// <param name="from">true: 'from language' /// false: 'to language'</param> public bool CheckLangOptions(DropboxType type) { IWebElement dropBox = GetLangElement(type); IList <IWebElement> langOptions = GetLangOptions(type); int optionsCount = langOptions.Count; dropBox.Click(); for (int dropBoxOption = 0; dropBoxOption < optionsCount; dropBoxOption++) { IWebElement option = langOptions[dropBoxOption]; if (option.GetAttribute("text").Equals("Русский") && type == DropboxType.From || option.GetAttribute("text").Equals("Английский") && type == DropboxType.To) { // It is a known issue, that this might occasionally not work with Firefox SelectElement selectEl = new SelectElement(dropBox); selectEl.SelectByIndex(dropBoxOption); return(true); } } return(false); }
/// <summary> /// Options of 'from/to language' dropbox. /// </summary> /// <param name="from">true: from language /// false: to language</param> /// <returns>Ilist of IWebElements, options of dropbox</returns> IList <IWebElement> GetLangOptions(DropboxType type) { return(new SelectElement(GetLangElement(type)).Options); }