private void ChangeLanguage() { BaseElement element = settings.Browser.Window.FindElement <Contaner>(By.XPath(LanguageButton)); Action <string> logger = (string msg) => Log(LogType.Info, msg, null, null); var data = new LanguageDropDown(element, logger, settings.Browser, pageSettings.Timeout); if (data.Items.Any(x => x.Name == LocalisationKeeper.LanguageNames[GenericParams.Language][pageSettings.Language])) { foreach (var item in data.Items) { if (item.Name == LocalisationKeeper.LanguageNames[GenericParams.Language][pageSettings.Language]) { item.Click(); BrowserWait.Wait(pageSettings.Timeout, (IBrowser b) => { return(b.Window.Title == LocalisationKeeper.Get(Test_1.Title, pageSettings.Language)); }); break; } } } else { element.Click(); } }
public IWebElement HCPFirstName(string HcpFirstName) { var insuliaSpecificFirstName = char.ToUpper(HcpFirstName[0]) + HcpFirstName.Substring(1).ToLower(); var t = BrowserWait.Until((Browser) => Browser.FindElement(By.XPath($"//tbody/tr/td[contains(text(),'{insuliaSpecificFirstName}')]"))); return(t); }
public virtual void ValidateThatMainPageIsOpened() { //BrowserWait.WaitForDocumentReadyStateComplete(); var element = Map.WrestlersTabHeading; BrowserWait.WaitForElementIsVisible(element); }
public bool WaitForPage() { // Wait until a page is fully loaded via JavaScript //WebDriverWait wait = new WebDriverWait(.driver, TimeSpan.FromSeconds(30)); //wait.Until((x) => //{ // return ((IJavaScriptExecutor)this.driver).ExecuteScript( // "return document.readyState").Equals("complete"); //}); var element = BrowserWait.Until(condition => { try { return(((IJavaScriptExecutor)Browser).ExecuteScript( "return document.readyState").Equals("complete")); } catch (StaleElementReferenceException) { return(false); } catch (NoSuchElementException) { return(false); } }); return(element); }
public virtual bool IsInvisible(By by) { try { BrowserWait.Until(condition: ExpectedConditions.InvisibilityOfElementLocated(by)); return(true); } catch (NoSuchElementException) { return(false); } }
private Link GetDropDownElement(string divLocator, string elementLocator) { Log(LogType.Info, $"Mouse over to dropdown element", null, null); return(BrowserWait.Wait(pageSettings.Timeout, (IBrowser b) => { var div = b.Window.FindElement <Contaner>(By.XPath(divLocator)); b.MouseActions.MoveToElement(div).Perform(); Link element = b.Window.FindElement <Link>(By.XPath(elementLocator)); return (element.IsExists && element.Displayed ? element : null); }, null, typeof(NoSuchElementException), typeof(StaleElementReferenceException))); }
public virtual bool IsPageTitle(string title) { try { BrowserWait.Until(condition: ExpectedConditions.TitleContains(title)); return(true); } catch (NoSuchElementException) { return(false); } }
private ReadOnlyCollection <Link> WaitForElements(IBrowser b, TimeSpan timeout) { BrowserWait wait = new BrowserWait(b, timeout); wait.IgnoreExceptionTypes(typeof(NoSuchElementException)); Contaner contaner = wait.Until(x => { Contaner div = b.Window.FindElement <Contaner>(By.XPath(DDMenuSelector)); return((!div.Disabled && !div.Disabled && div.Disabled) ? div : null); }); return(contaner.FindElements <Link>(By.TagName("a"))); }
public virtual bool IsVisible(By by) { try { BrowserWait.Until(condition: ExpectedConditions.ElementIsVisible(by)); return(true); } catch (TimeoutException) { return(false); } catch (NoSuchElementException) { return(false); } }
public virtual bool IsClickable(By by) { try { var found = BrowserWait.Until(condition: ExpectedConditions.ElementToBeClickable(by)); if (found != null) { return(true); } return(false); } catch (NoSuchElementException) { return(false); } }
private void WebBrowser_DocumentCompleted(object sender, System.Windows.Forms.WebBrowserDocumentCompletedEventArgs e) { try { if (sender == webHtml) { ((System.Windows.Forms.WebBrowser)sender).Document.Window.Error += new System.Windows.Forms.HtmlElementErrorEventHandler(Window_Error); var browser = sender as System.Windows.Forms.WebBrowser; foreach (System.Windows.Forms.HtmlElement link in browser.Document.Links) { try { if (string.IsNullOrEmpty(link.GetAttribute("href"))) { continue; } link.Click += WebBrowser_LinkClick; } catch (Exception ex) { ex.ERROR(); continue; } } WebBrowserReplaceImageSource(browser); } } #if DEBUG catch (Exception ex) { if (ParentWindow is ContentWindow) { (ParentWindow as ContentWindow).SetPrefetchingProgress(-1, state: TaskStatus.Faulted); } //BrowserWait.Fail(); ex.Message.DEBUG(); } #else catch (Exception ex) { ex.ERROR(); BrowserWait.Fail(); } #endif finally { if (ParentWindow is ContentWindow) { (ParentWindow as ContentWindow).SetPrefetchingProgress(-1, state: TaskStatus.RanToCompletion); } //BrowserWait.Hide(); } }
private bool CheckDownloading(string[] files, string comparationPattern, TimeSpan timeout, string pathToDownload, int step) { bool ans; try { bool Compare(string[] files) { foreach (var item in files) { if (Regex.Match(item, comparationPattern, RegexOptions.IgnoreCase).Success) { return(true); } } return(false); } ans = BrowserWait.Wait(timeout, browser => { var newFiles = Directory.GetFiles(pathToDownload); return(files.Count() < newFiles.Count() && Compare(newFiles)); }); } catch (Exception) { ans = false; } if (ans) { loggers.Log(LogType.Info, "File downloaded", System.Reflection.MethodBase.GetCurrentMethod().Name, step); } else { loggers.Log(LogType.Warning, "File wasn`t downloaded", System.Reflection.MethodBase.GetCurrentMethod().Name, step); } return(ans); }
public virtual bool IsReady(IWebElement e) { BrowserWait.IgnoreExceptionTypes(typeof(NoSuchElementException), typeof(ElementNotVisibleException)); var element = BrowserWait.Until(condition => { try { return(e.Displayed); } catch (StaleElementReferenceException) { return(false); } catch (NoSuchElementException) { return(false); } }); return(element); }
public SelectedGamePage(TimeSpan timeout, AgeVerificationData verificationData, Language ln, string gameName, string pathToLogFile) : base(null, true, LoggerCreator.GetLogger(LoggerTypes.FileLogger, null, pathToLogFile)) { AgeVerificationPage verificationPage = new AgeVerificationPage(pathToLogFile); if (verificationPage.IsPageOpened) { verificationPage.Day.SelectByValue(verificationData.Day.ToString()); verificationPage.Month.SelectByValue(LocalisationKeeper.Get(verificationData.Month, ln)); verificationPage.Year.SelectByValue(verificationData.Year.ToString()); verificationPage.Submit(); } this.gameName = gameName; BrowserWait.Wait(timeout, (IBrowser b) => { return(b.Window.FindElement <Contaner>(By.XPath(programNameLocator)).InnerHTML == gameName); }, null, typeof(NoSuchElementException)); Name = gameName; this.timeout = timeout; this.language = ln; }
public IWebElement HCPLastName(string HcpLastName) { return(BrowserWait.Until((Browser) => Browser.FindElement(By.XPath($"//tbody/tr/td[contains(text(),'{HcpLastName.ToUpper()}')]")))); }
public IWebElement HCPInputFieldBasedOnValue(string targetedValue) { return(BrowserWait.Until((Browser) => Browser.FindElement(By.XPath($"//[@value='{targetedValue}']")))); }
public IWebElement HCPInputFieldBasedLabel(string targetedValue) { var tt = BrowserWait.Until((Browser) => Browser.FindElement(By.XPath($"//*[label='{targetedValue}']"))); return(tt); }
private void WaitForLogo() { BrowserWait.Until <IWebElement>((d) => { return(d.FindElement(By.Id("gh-logo"))); }); }
public virtual void ValidateThatSaveIconIsAvailable() { BrowserWait.WaitForElementIsVisible(Map.SaveButton); }
public virtual void ValidateThatNewWrestlerTabIsDisplayed() { BrowserWait.WaitForElementIsVisible(Map.NewWrestlerTabHeading); }
public static string getDialogTitle() { BrowserWait.Until(ExpectedConditions.ElementIsVisible(By.CssSelector(DialogPage.dialogTitle))); return(Browser.FindElement(By.CssSelector(DialogPage.dialogTitle)).Text); }
public IWebElement HCPInformationByText(string hcpTargetedInfo) { return(BrowserWait.Until((Browser) => Browser.FindElement(By.XPath($"//tbody/tr/td[contains(text(),'{hcpTargetedInfo}')]")))); }
public void ExpandDiv(DivSection section, bool expand) { Log.Info($"{GetType().Name}: ExpandDiv(): {section},{expand}"); IWebElement button; IWebElement div; switch (section) { case DivSection.TestNavMenu: button = Browser.FindElement(_navMenuDivButton); div = Browser.FindElement(_navMenuDiv); break; case DivSection.TestTextField: button = Browser.FindElement(_textFieldDivButton); div = Browser.FindElement(_textFieldDiv); break; case DivSection.TestTextInput: button = Browser.FindElement(_textInputDivButton); div = Browser.FindElement(_textInputDiv); break; case DivSection.TestSelectInput: button = Browser.FindElement(_selectDivButton); div = Browser.FindElement(_selectDiv); break; case DivSection.TestCheckboxInput: button = Browser.FindElement(_checkboxDivButton); div = Browser.FindElement(_checkboxDiv); break; case DivSection.TestRadioInput: button = Browser.FindElement(_radioDivButton); div = Browser.FindElement(_radioDiv); break; case DivSection.TestImage: button = Browser.FindElement(_imageDivButton); div = Browser.FindElement(_imageDiv); break; case DivSection.TestTable: button = Browser.FindElement(_tableDivButton); div = Browser.FindElement(_tableDiv); break; case DivSection.TestModal: button = Browser.FindElement(_modalDivButton); div = Browser.FindElement(_modalDiv); break; case DivSection.TestTabMenuNav: button = Browser.FindElement(_tabMenuDivButton); div = Browser.FindElement(_tabMenuDiv); break; case DivSection.TestBrowserConsole: button = Browser.FindElement(_browserConsoleDivButton); div = Browser.FindElement(_browserConsoleDiv); break; default: var msg = $"{GetType().Name}: Unsupported DivSection={section} used for ExpandDiv"; Log.Error(msg); throw new Exception(msg); } if (!expand && div.Displayed) { button.Click(); BrowserWait.Until(driver => div.GetAttribute("class").Contains("collapse")); BrowserWait.Until(driver => !div.Displayed); return; } if (expand && !div.Displayed) { button.Click(); BrowserWait.Until(driver => div.GetAttribute("class").Contains("collapse in")); BrowserWait.Until(driver => div.Displayed); } }
public IWebElement HCPConfirmationEmail(string HcpConfirmationEmail) { return(BrowserWait.Until((Browser) => Browser.FindElement(By.XPath($"//tbody/tr/td[contains(text(),'{HcpConfirmationEmail}')]")))); }
public static void fillInput(string text) { BrowserWait.Until(ExpectedConditions.ElementIsVisible(By.CssSelector(DialogPage.input))); Browser.FindElement(By.CssSelector(DialogPage.input)).SendKeys(text); }