コード例 #1
0
        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();
            }
        }
コード例 #2
0
        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);
        }
コード例 #3
0
        public virtual void ValidateThatMainPageIsOpened()
        {
            //BrowserWait.WaitForDocumentReadyStateComplete();
            var element = Map.WrestlersTabHeading;

            BrowserWait.WaitForElementIsVisible(element);
        }
コード例 #4
0
        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);
        }
コード例 #5
0
 public virtual bool IsInvisible(By by)
 {
     try
     {
         BrowserWait.Until(condition: ExpectedConditions.InvisibilityOfElementLocated(by));
         return(true);
     }
     catch (NoSuchElementException)
     {
         return(false);
     }
 }
コード例 #6
0
        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)));
        }
コード例 #7
0
 public virtual bool IsPageTitle(string title)
 {
     try
     {
         BrowserWait.Until(condition: ExpectedConditions.TitleContains(title));
         return(true);
     }
     catch (NoSuchElementException)
     {
         return(false);
     }
 }
コード例 #8
0
        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")));
        }
コード例 #9
0
 public virtual bool IsVisible(By by)
 {
     try
     {
         BrowserWait.Until(condition: ExpectedConditions.ElementIsVisible(by));
         return(true);
     }
     catch (TimeoutException)
     {
         return(false);
     }
     catch (NoSuchElementException)
     {
         return(false);
     }
 }
コード例 #10
0
 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);
     }
 }
コード例 #11
0
ファイル: BrowserPage.xaml.cs プロジェクト: netcharm/PixivWPF
        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();
            }
        }
コード例 #12
0
        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);
        }
コード例 #13
0
        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);
        }
コード例 #14
0
        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;
        }
コード例 #15
0
 public IWebElement HCPLastName(string HcpLastName)
 {
     return(BrowserWait.Until((Browser) => Browser.FindElement(By.XPath($"//tbody/tr/td[contains(text(),'{HcpLastName.ToUpper()}')]"))));
 }
コード例 #16
0
 public IWebElement HCPInputFieldBasedOnValue(string targetedValue)
 {
     return(BrowserWait.Until((Browser) => Browser.FindElement(By.XPath($"//[@value='{targetedValue}']"))));
 }
コード例 #17
0
        public IWebElement HCPInputFieldBasedLabel(string targetedValue)
        {
            var tt = BrowserWait.Until((Browser) => Browser.FindElement(By.XPath($"//*[label='{targetedValue}']")));

            return(tt);
        }
コード例 #18
0
 private void WaitForLogo()
 {
     BrowserWait.Until <IWebElement>((d) => { return(d.FindElement(By.Id("gh-logo"))); });
 }
コード例 #19
0
 public virtual void ValidateThatSaveIconIsAvailable()
 {
     BrowserWait.WaitForElementIsVisible(Map.SaveButton);
 }
コード例 #20
0
 public virtual void ValidateThatNewWrestlerTabIsDisplayed()
 {
     BrowserWait.WaitForElementIsVisible(Map.NewWrestlerTabHeading);
 }
コード例 #21
0
 public static string getDialogTitle()
 {
     BrowserWait.Until(ExpectedConditions.ElementIsVisible(By.CssSelector(DialogPage.dialogTitle)));
     return(Browser.FindElement(By.CssSelector(DialogPage.dialogTitle)).Text);
 }
コード例 #22
0
 public IWebElement HCPInformationByText(string hcpTargetedInfo)
 {
     return(BrowserWait.Until((Browser) => Browser.FindElement(By.XPath($"//tbody/tr/td[contains(text(),'{hcpTargetedInfo}')]"))));
 }
コード例 #23
0
        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);
            }
        }
コード例 #24
0
 public IWebElement HCPConfirmationEmail(string HcpConfirmationEmail)
 {
     return(BrowserWait.Until((Browser) => Browser.FindElement(By.XPath($"//tbody/tr/td[contains(text(),'{HcpConfirmationEmail}')]"))));
 }
コード例 #25
0
 public static void fillInput(string text)
 {
     BrowserWait.Until(ExpectedConditions.ElementIsVisible(By.CssSelector(DialogPage.input)));
     Browser.FindElement(By.CssSelector(DialogPage.input)).SendKeys(text);
 }