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();
            }
        }
        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)));
        }
Example #3
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);
        }
        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;
        }