Ejemplo n.º 1
0
        private void byChannel(DateTime date, byte[] bytes, int nChannel, BaseDriver myDriver)
        {
            //Структура архивной записи канала sa_tsrv_023.pdf
            try
            {
                var mass = Helper.ToSingle(bytes, 0) / 1000f;
                Data.Add(new Data(string.Format("Масса по каналу {0}", nChannel), MeasuringUnitType.tonn, date, mass));

                var temperature = (double)Helper.ToInt16(bytes, 4) / 100.0;
                Data.Add(new Data(string.Format("Температура по каналу {0}", nChannel), MeasuringUnitType.C, date, temperature));

                var pressure = (double)Helper.ToUInt16(bytes, 6) / 100.0;
                Data.Add(new Data(string.Format("Давление по каналу {0}", nChannel), MeasuringUnitType.MPa, date, pressure));

                var volume = Helper.ToUInt32(bytes, 8);
                Data.Add(new Data(string.Format("Суммарный объем по каналу {0}", nChannel), MeasuringUnitType.m3, date, volume));

                var statusWord = Helper.ToUInt16(bytes, 12);
                Data.Add(new Data(string.Format("Слово состояние по каналу {0}", nChannel), MeasuringUnitType.min, date, statusWord));
            }
            catch (Exception ex2)
            {
                myDriver.OnSendMessage(string.Format(string.Format("ошибка в byChannel: {0}", ex2.Message)));
            }
        }
 public IAbstractPage NavigateTo <TPage>(string url) where TPage : IAbstractPage
 {
     BaseDriver.NavigateTo(url);
     return((TPage)typeof(TPage)
            .GetConstructor(new[] { typeof(BaseDriver) })
            .Invoke(new object[] { BaseDriver }));
 }
        /// <summary>
        /// Get New Window Handle
        /// </summary>
        /// <returns>Returns new window handle</returns>
        public string GetNewWindowTitle()
        {
            IWebDriver newtWindowHandle = null;
            string     oldtWindowHandle = BaseDriver.CurrentWindowHandle;

            try
            {
                ReadOnlyCollection <string> windowHandles = BaseDriver.WindowHandles;
                if (windowHandles.Count > 1)
                {
                    foreach (string handle in windowHandles)
                    {
                        if (handle != oldtWindowHandle)
                        {
                            newtWindowHandle = BaseDriver.SwitchTo().Window(handle);
                        }
                    }
                }
                else
                {
                    newtWindowHandle = BaseDriver.SwitchTo().Window(oldtWindowHandle);
                }
            }
            catch (Exception e)
            {
                LogHandler.Error("SwitchToTab::NoSuchElementException - " + e.Message);
                throw new NoSuchElementException("SwitchToTab::" + e.Message);
            }
            return(newtWindowHandle.Title);
        }
        /// <summary>
        /// Helper Method which scans all possible active drivers.
        /// </summary>
        private void GetActiveDriverReporter()
        {
            List <object> drivers = new List <object>
            {
                BaseDriver.GetInstance(),
                          GenericDriver.GetInstance(),
                AndroidDriver <AppiumWebElement> .GetInstance(),
                IOSDriver <AppiumWebElement> .GetInstance(),
            };

            foreach (var driver in drivers)
            {
                if (driver != null)
                {
                    if (driver is IWebDriver currentDriver)
                    {
                        this.Reporter = currentDriver.Report();
                    }
                    else
                    {
                        this.Reporter = ((GenericDriver)driver).Report();
                    }

                    return;
                }
            }

            // If driver is null, there is no active driver session
            throw new SdkException("No active driver instance found for reporting");
        }
Ejemplo n.º 5
0
 public PagesFramework(BaseDriver driver)
 {
     this.testData = XDocument.Load(Path.GetFullPath(@"C:\TestData\AutomationTest.xml"));
     this.driver   = driver;
     this.pages    = new Pages(this.driver);
     //this.workflows = new Workflows();
 }
        private static object Decorate(Type targetType, BaseDriver baseDriver, string link)
        {
            return string.IsNullOrEmpty(link) ?
                 targetType.GetConstructor(new[] { typeof(BaseDriver), }).Invoke(new object[] { baseDriver }) :
                 targetType.GetConstructor(new[] { typeof(BaseDriver), typeof(string) }).Invoke(new object[] { baseDriver, link });

        }
Ejemplo n.º 7
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DataHelper"/> class.
 /// </summary>
 /// <param name="driver">The driver.</param>
 /// <exception cref="NoNullAllowedException">driver can not be null.</exception>
 public DataHelper(BaseDriver driver)
 {
     this.Driver = driver; if (driver == null)
     {
         throw new ArgumentNullException("driver can not be null.");
     }
 }
        public static object CreateProxy(BaseDriver baseDriver, string name, Type elementOfGenericListType, IElementLocator locator, IEnumerable <By> bys, bool cacheLookups)
        {
            var tlist = typeof(IList <>).MakeGenericType(elementOfGenericListType);
            var proxy = typeof(DispatchProxy).GetMethod("Create").MakeGenericMethod(tlist, typeof(CustomElementListProxy)).Invoke(null, new object[] { });

            ((CustomElementListProxy)proxy).SetSearchProperties(baseDriver, name, elementOfGenericListType, locator, bys, cacheLookups);
            return(proxy);
        }
Ejemplo n.º 9
0
        public void ClassCleanup()
        {
            // Runs once after all tests in this class are executed. (Optional)
            // Not guaranteed that it executes instantly after all tests from the class.

            // Disppose the instance of webdriver
            BaseDriver.StopBrowser();
            //driver.Dispose();
        }
Ejemplo n.º 10
0
        /// <summary>
        ///     Called by Unity to initialize the <seealso cref="BaseBattleDriver"/> whether it is or is not active.
        /// </summary>
        protected virtual void Awake()
        {
            this.spriteManager  = this.GetComponent <SpriteManager>();
            this.spriteAnimator = this.GetComponent <SpriteAnimator>();
            this.entityDriver   = this.GetComponent <BaseDriver>();
            this.highlight      = this.GetComponent <Highlighter>();

            this.battleName = this.possibleBattleNames != null?this.possibleBattleNames.GetRandomItem() : this.battleName;
        }
 public BaseElement(IWebElement Element, BaseDriver Driver, string ElementName)
 {
     IWebElement        = Element;
     BaseDriver         = Driver;
     WebWaiter          = BaseDriver.WebWaiter;
     Name               = ElementName;
     Logger             = BaseDriver.Logger;
     JavaScriptExecutor = new JavaScriptExecutor(IWebElement);
 }
Ejemplo n.º 12
0
        public string AddNewTask()
        {
            string newTask = "Task - " + BaseDriver.ReturnStringWithRandomCharacters(2);

            myTaskPage.ClickMyTask();
            myTaskPage.FillNameTask(newTask);
            myTaskPage.ClickAddTask();
            return(newTask);
        }
        protected void SetSearchProperties(BaseDriver baseDriver, string name, Type elementOfGenericListType, IElementLocator locator, IEnumerable <By> bys, bool cache)
        {
            ElementOfGenericListType = elementOfGenericListType;
            BaseDriver = baseDriver;
            Name       = name;

            Locator = locator;
            Bys     = bys;
            Cache   = cache;
        }
Ejemplo n.º 14
0
        public void GoogleTest()
        {
            BaseDriver.Navigate().GoToUrl("http://www.google.com/");
            IWebElement query = BaseDriver.FindElement(By.Name("q"));

            query.SendKeys("Bread" + Keys.Enter);
            Thread.Sleep(2000);
            Assert.AreEqual("Bread - Google Search", BaseDriver.Title);
            BaseDriver.Quit();
        }
        /// <summary>
        ///     Finds all fighters with the same tag as <paramref name="leaderBattleDriver"/>
        ///     and adds the ones not participating to <seealso cref="DeactivatableGameObjects"/>
        /// </summary>
        /// <param name="leaderBattleDriver">The leader of the bunch</param>
        /// <returns>A list of <seealso cref="BaseBattleDriver"/>s</returns>
        private List <BaseBattleDriver> FindFighters(BaseBattleDriver leaderBattleDriver)
        {
            // Find all GameObjects with the same tag as the leader
            GameObject[] allFighters = GameObject.FindGameObjectsWithTag(leaderBattleDriver.tag);

            List <BaseBattleDriver> listOfFighters = new List <BaseBattleDriver>();

            BaseDriver leaderDriver = leaderBattleDriver.GetComponent <BaseDriver>();

            // Check each of them
            foreach (GameObject fighter in allFighters)
            {
                BaseDriver driver = fighter.GetComponent <BaseDriver>();

                if (driver != null && (driver.Leader == leaderDriver || driver == leaderDriver))
                {
                    // Required component; should never be missing
                    listOfFighters.Add(fighter.GetComponent <BaseBattleDriver>());
                }
                else
                {
                    fighter.SetActive(false);
                    this.DeactivatableGameObjects.Add(fighter);
                }
            }

            // Sort them
            List <BaseBattleDriver> listOfFightersSorted = new List <BaseBattleDriver>(listOfFighters.Count);

            for (int i = 0; i < listOfFighters.Count; i++)
            {
                foreach (BaseBattleDriver battleDriver in listOfFighters)
                {
                    BaseDriver driver = battleDriver.entityDriver;
                    int        number = 0;
                    while (driver.Following != null)
                    {
                        driver = driver.Following;
                        ++number;

                        if (number > listOfFighters.Count)
                        {
                            throw new RPGException(RPGException.Cause.DriverLoopingFollowing);
                        }
                    }

                    if (number == i)
                    {
                        listOfFightersSorted.Add(battleDriver);
                    }
                }
            }

            return(listOfFightersSorted);
        }
Ejemplo n.º 16
0
        public static void closebrowser()
        {
            Thread.Sleep(2000);
            Screenshot sh = ((ITakesScreenshot)BaseDriver.driver).GetScreenshot();

            sh.SaveAsFile(Resource1.screenShots, ScreenshotImageFormat.Jpeg);

            BaseDriver.close();

            //BaseDriver.quit();
        }
Ejemplo n.º 17
0
        public void ClassInit()
        {
            // Executes once for the test class. (Optional)
            // Create the instance of Web Driver => Chrome driver
            //driver = new ChromeDriver();

            //_page = new MainPage(driver);

            // Using for page singleton
            BaseDriver.StartBrowser(BrowserType.Chrome);
        }
 /// <summary>
 ///
 /// </summary>
 /// <returns></returns>
 public IAlert SwitchToAlert()
 {
     try
     {
         WaitsHandler.WaitForAlert(BaseDriver, "");
         return(BaseDriver.SwitchTo().Alert());
     }
     catch (Exception e)
     {
         LogHandler.Error("SwitchToAlert::Exception - " + e.Message);
         throw new NoSuchElementException("SwitchToAlert::" + e.Message);
     }
 }
        private TElement ElementBy <TElement>(By by) where TElement : IElement
        {
            var WebElement = BaseDriver.FindElement(by);

            if (WebElement == null)
            {
                Logger.Info("Unable to locate : " + typeof(IElement).ToString() + " element using: " + by.ToString());
                return(default(TElement));
            }
            else
            {
                return((TElement)typeof(TElement)
                       .GetConstructor(new[] { typeof(IWebElement), typeof(BaseDriver), typeof(string) })
                       .Invoke(new object[] { WebElement, BaseDriver, by.ToString() }));
            }
        }
Ejemplo n.º 20
0
        /// <summary>
        /// Helper method to determine whether an element is displayed within the given timeout.
        /// </summary>
        /// <param name="driver">The current driver in use.</param>
        /// <param name="element">The element to check.</param>
        /// <returns>True if element is displayed within the default timeout, false otherwise.</returns>
        public static bool IsDisplayed(BaseDriver driver, By element)
        {
            WebDriverWait wait = new WebDriverWait(driver, TIMEOUT);

            return(wait.Until(d =>
            {
                try
                {
                    IWebElement tempElement = driver.FindElement(element);
                    return tempElement.Displayed;
                }
                catch
                {
                    return false;
                }
            }));
        }
Ejemplo n.º 21
0
        public Response65(byte[] data, BaseDriver myDriver)
            : base(data)
        {
            Data = new List <Common.Data>();

            var length = data[2];
            int start  = 3;                                 //0,1,2

            var seconds = Helper.ToUInt32(data, start + 0); //3,4,5,6

            //если данные нулевые, игнорим их
            if (seconds == 0)
            {
                return;
            }

            var    date = new DateTime(1970, 1, 1).AddSeconds(seconds);
            Driver D    = new Driver();

            byte[] bytes = null;

            //По теплосистемам  Документ: sa_tsrv_023
            for (int nHeatSystem = 1; nHeatSystem <= 3; nHeatSystem++)
            {
                bytes = data.Skip(3 + 4 + (nHeatSystem - 1) * 44).Take(44).ToArray();  //7-2=5, 51-2 =49,  и далее
                heatSystem(date, bytes, nHeatSystem, myDriver);
            }

            //По каналам  Документ: sa_tsrv_023
            for (int nChannel = 0; nChannel <= 6; nChannel++)
            {
                bytes = data.Skip(3 + 136 + (nChannel - 1) * 14).Take(14).ToArray();   //139, 153 и далее
                byChannel(date, bytes, nChannel, myDriver);
            }

            //Суммарное тепло
            var heatSumma = Helper.ToSingle(data, 3 + 234);

            Data.Add(new Data(string.Format("Суммарное тепло"), MeasuringUnitType.Gkal, date, heatSumma));


            for (int nElement = 0; nElement <= (Data.Count - 1); nElement++)
            {
                myDriver.OnSendMessage(string.Format(" {0} Value :{1} {2}", Data[nElement].ParameterName, Data[nElement].Value, Data[nElement].MeasuringUnit));
            }
        }
Ejemplo n.º 22
0
        private void heatSystem(DateTime date, byte[] bytes, int nHeatSystem, BaseDriver myDriver)
        {
            //Структура архивной записи теплосистемы sa_tsrv_023.pdf
            try
            {
                var heat1 = Helper.ToSingle(bytes, 0) / 4.1868;
                Data.Add(new Data(string.Format("Теплосистема {0} Теплота 1", nHeatSystem), MeasuringUnitType.Gkal, date, heat1));

                var heat2 = Helper.ToSingle(bytes, 4) / 4.1868;
                Data.Add(new Data(string.Format("Теплосистема {0} Теплота 2", nHeatSystem), MeasuringUnitType.Gkal, date, heat2));

                var heat3 = Helper.ToSingle(bytes, 8) / 4.1868;
                Data.Add(new Data(string.Format("Теплосистема {0} Теплота 3", nHeatSystem), MeasuringUnitType.Gkal, date, heat3));

                var timeWork = Helper.ToUInt32(bytes, 12);
                Data.Add(new Data(string.Format("Теплосистема {0} Время работы", nHeatSystem), MeasuringUnitType.min, date, timeWork));

                var timeIdle = Helper.ToUInt32(bytes, 16);
                Data.Add(new Data(string.Format("Теплосистема {0} Время простоя", nHeatSystem), MeasuringUnitType.min, date, timeIdle));

                var timeEmergency1 = Helper.ToUInt32(bytes, 20);
                Data.Add(new Data(string.Format("Теплосистема {0} Время нештатной ситуации 1", nHeatSystem), MeasuringUnitType.min, date, timeEmergency1));

                var timeEmergency2 = Helper.ToUInt32(bytes, 24);
                Data.Add(new Data(string.Format("Теплосистема {0} Время нештатной ситуации 2", nHeatSystem), MeasuringUnitType.min, date, timeEmergency2));

                var timeEmergency3 = Helper.ToUInt32(bytes, 28);
                Data.Add(new Data(string.Format("Теплосистема {0} Время нештатной ситуации 3", nHeatSystem), MeasuringUnitType.min, date, timeEmergency3));

                var timeEmergencyHC0 = Helper.ToUInt32(bytes, 32);
                Data.Add(new Data(string.Format("Теплосистема {0} Время нештатной ситуации HC0", nHeatSystem), MeasuringUnitType.min, date, timeEmergencyHC0));

                var statusWord = Helper.ToUInt32(bytes, 40);
                Data.Add(new Data(string.Format("Теплосистема {0} Слово состояние", nHeatSystem), MeasuringUnitType.min, date, statusWord));
            }
            catch (Exception ex2)
            {
                myDriver.OnSendMessage(string.Format(string.Format("ошибка в heatSystem: {0}", ex2.Message)));
            }
        }
Ejemplo n.º 23
0
        public void CompareUserHistory()
        {
            logonStrategy.LogOn(UserPool.GetUser());

            var cookies = BaseDriver.GetBrowserCookies();

            var userService = Scope.Resolve <IUserService>();

            string path = $"{TestContext.CurrentContext.Test.Name} ({_browser})";

            userService.DownloadHistory(cookies, path);

            var userFileHistory = UserHistoryData.GetUserHistory(path);

            var userHistory = userService.GetUserHistory(cookies);

            CollectionAssert.IsNotEmpty(userHistory);

            CollectionAssert.IsNotEmpty(userFileHistory);

            CompareHistories(userFileHistory, userHistory);
        }
Ejemplo n.º 24
0
        public void CompareUserProgress()
        {
            logonStrategy.LogOn(UserPool.GetUser());

            var progress = Scope.Resolve <IUserService>().GetStatistics(BaseDriver.GetBrowserCookies()).UserProgress;

            var statistics = Scope.Resolve <ITutorialSection>().WaitForLoading();

            var groups    = statistics.GetStatsByType(StatisticsType.Groups);
            var tutorials = statistics.GetStatsByType(StatisticsType.Tutorials);
            var missions  = statistics.GetStatsByType(StatisticsType.Missions);

            Assert.Multiple(() =>
            {
                Logger.Info($"From User service {progress.GroupsTotal}, from the main page {groups.Total}");
                Assert.That(
                    progress.GroupsTotal.Equals(groups.Total), $"{progress.GroupsTotal} not equals to {groups.Total}");

                Logger.Info($"From User service {progress.GroupsCompleted}, from the main page {groups.Completed}");
                Assert.That(
                    progress.GroupsCompleted.Equals(groups.Completed), $"{progress.GroupsCompleted} not equals to {groups.Completed}");

                Logger.Info($"From User service {progress.MissionsTotal}, from the main page {missions.Total}");
                Assert.That(
                    progress.MissionsTotal.Equals(missions.Total), $"{progress.MissionsTotal} not equals to {missions.Total}");

                Logger.Info($"From User service {progress.MissionsCompleted}, from the main page {missions.Completed}");
                Assert.That(
                    progress.MissionsCompleted.Equals(missions.Completed), $"{progress.MissionsCompleted} not equals to {missions.Completed}");

                Logger.Info($"From User service {progress.TutorialTotal}, from the main page {tutorials.Total}");
                Assert.That(
                    progress.TutorialTotal.Equals(tutorials.Total), $"{progress.TutorialTotal} not equals to {tutorials.Total}");

                Logger.Info($"From User service {progress.TutorialCompleted}, from the main page {tutorials.Completed}");
                Assert.That(
                    progress.TutorialCompleted.Equals(tutorials.Completed), $"{progress.TutorialCompleted} not equals to {tutorials.Completed}");
            });
        }
        /// <summary>
        /// Check if Tab is present
        /// </summary>
        /// <param name="tabtitle">BTN number</param>
        /// <returns>true=if ihdcase tab is present; false=if it is not present</returns>
        public bool IsWindowPresent(string windowtitle)
        {
            WaitsHandler.WaitForAjaxToComplete(BaseDriver);
            IWebDriver currentWindowHandle = null;

            try
            {
                ReadOnlyCollection <string> windowHandles = BaseDriver.WindowHandles;
                foreach (string handle in windowHandles)
                {
                    currentWindowHandle = BaseDriver.SwitchTo().Window(handle);
                    if (currentWindowHandle.Url.ToLower().Contains(windowtitle.ToLower()) || currentWindowHandle.Title.ToLower().Contains(windowtitle.ToLower()))
                    {
                        return(true);
                    }
                }
            }
            catch (Exception)
            {
                //logger
            }
            return(false);
        }
        /// <summary>
        /// Switch to a different windows.
        /// </summary>
        /// <param name="title">the windows title</param>
        public IWebDriver SwitchToTab(string title)
        {
            IWebDriver currentWindowHandle = null;

            try
            {
                ReadOnlyCollection <string> windowHandles = BaseDriver.WindowHandles;
                foreach (string handle in windowHandles)
                {
                    currentWindowHandle = BaseDriver.SwitchTo().Window(handle);
                    if (currentWindowHandle.Url.ToLower().Contains(title.ToLower()) || currentWindowHandle.Title.ToLower().Contains(title.ToLower()))
                    {
                        return(BaseDriver.SwitchTo().Window(handle));
                    }
                }
            }
            catch (Exception e)
            {
                LogHandler.Error("SwitchToTab::NoSuchElementException - " + e.Message);
                throw new NoSuchElementException("SwitchToTab::" + e.Message);
            }
            return(BaseDriver);
        }
Ejemplo n.º 27
0
 public Registration(BaseDriver driver) : base(driver)
 {
 }
Ejemplo n.º 28
0
 public AutomationpracticeMain(BaseDriver baseDriver, string link) : base(baseDriver, link)
 {
 }
Ejemplo n.º 29
0
 public AutomationpracticeMain(BaseDriver Driver) : base(Driver)
 {
 }
Ejemplo n.º 30
0
 public W3TablePage(BaseDriver baseDriver) : base(baseDriver)
 {
 }