Beispiel #1
0
        public static AutomationTestContext DeleteApp(this AutomationTestContext context)
        {
            // close the object to ensure settings visibilty
            var res = context.tinyWait.Until(ExpectedConditions.ElementIsVisible(By.ClassName("ba-icon-objects")));

            res.Click();

            // wait for fadein animation
            Thread.Sleep(500);

            // open sttings menu
            res = context.tinyWait.Until(ExpectedConditions.ElementIsVisible(By.ClassName("ba-icon-settings")));
            context.driver.MoveTo(By.ClassName("ba-icon-settings"));
            res.Click();

            // wait for fadein animation
            Thread.Sleep(500);
            context.driver.FindElements(By.CssSelector("[ng-click=\"nav.goTo('app.edit')\"]")).First(c => c.Enabled).Click();

            context.driver.FindElements(By.CssSelector("[ng-click='settings.delete()']")).First(c => c.Enabled).Click();

            // wait for fadein animation
            Thread.Sleep(500);

            context.tinyWait.Until(ExpectedConditions.ElementIsVisible(By.CssSelector("[ng-bind='okBtnText']"))).Click();

            // wait for fadeout animation
            Thread.Sleep(1000);

            return(context);
        }
Beispiel #2
0
        public AppPageHelper(AutomationTestContext current)
        {
            this.current = current;

            // create availableApps
            _availableApps = GetAllApps(current);
        }
Beispiel #3
0
        public static AutomationTestContext SignIn(this AutomationTestContext context)
        {
            context.tinyWait.Until((a) => { return(a.FindElement(By.Name("uEmail"))); }).SendKeys(context.username);
            context.driver.FindElement(By.Name("uPassword")).SendKeys(context.Password);
            context.driver.FindElements(By.ClassName("auth-button")).First(c => c.Enabled).Click();

            return(context);
        }
Beispiel #4
0
        public static AutomationTestContext GoToHomePage(this AutomationTestContext context)
        {
            //
            context.driver.Navigate().GoToUrl(context.WebPage);

            // Todo Assert
            return(context);
        }
Beispiel #5
0
        public static AutomationTestContext CloseIntercom(this AutomationTestContext context)
        {
            if (context.hasIntercom)
            {
                Console.WriteLine("Wait for intercom");
                context.tinyWait.Until(ExpectedConditions.ElementIsVisible(By.ClassName("intercom-launcher-hovercard-close")));
                context.tinyWait.Until((a) => { return(a.FindElement(By.ClassName("intercom-launcher-hovercard-close"))); }).Click();
            }

            return(context);
        }
Beispiel #6
0
        public static AutomationTestContext EnsureAppCreated(this AutomationTestContext context)
        {
            //var res = context.longWait.Until(ExpectedConditions.ElementIsVisible(By.ClassName("ba-icon-objects")));
            var res = context.longWait.Until(ExpectedConditions.ElementIsVisible(By.XPath("//strong[text()='Your app " + context.AppName + " is ready']")));

            if (res == null)
            {
                throw new ElementNotVisibleException("Can't find object menu in tab");
            }

            return(context);
        }
Beispiel #7
0
        public static AutomationTestContext FillSignUpPage(this AutomationTestContext context)
        {
            context.tinyWait.Until(ExpectedConditions.ElementExists(By.Name("uFullFirst")));

            //todo
            context.tinyWait.Until((a) => { return(a.FindElement(By.Name("uFullFirst"))); }).SendKeys("Ygal");
            context.driver.FindElement(By.Name("uEmail")).SendKeys(context.username);
            context.driver.FindElement(By.Name("Upassword")).SendKeys(context.Password);
            context.driver.FindElement(By.Name("confirm_password")).SendKeys(context.Password);
            context.tinyWait.Until(ExpectedConditions.ElementToBeClickable(By.ClassName("auth-button")));
            context.driver.FindElements(By.ClassName("auth-button")).First(c => c.Enabled).Click();
            return(context);
        }
Beispiel #8
0
        public static AutomationTestContext SelectItems(this AutomationTestContext context)
        {
            var res = context.tinyWait.Until(ExpectedConditions.ElementIsVisible(By.ClassName("ba-icon-objects")));

            res.Click();

            // wait for fadein animation
            Thread.Sleep(1000);
            context.driver.FindElements(By.CssSelector("[ng-click='nav.showTable(table)']")).First(c => c.Enabled).Click();

            res = context.longWait.Until(ExpectedConditions.ElementIsVisible(By.XPath("//strong[text()=' Object - items ']")));

            return(context);
        }
Beispiel #9
0
        public static AutomationTestContext AssertCreatedAppNotExist(this AutomationTestContext context)
        {
            //res = context.tinyWait.Until(ExpectedConditions.El(By.ClassName("ba-icon-settings")));

            Thread.Sleep(10 * 1000);
            var res = new AppPageHelper(context).AppExist(context.AppName);

            if (res == true)
            {
                throw new Exception("find app " + context.AppName + " but shouldn't");
            }
            Assert.IsFalse(res);

            return(context);
        }
Beispiel #10
0
        public static AutomationTestContext CreateApp(this AutomationTestContext context)
        {
            context.tinyWait.Until(ExpectedConditions.ElementIsVisible(By.Name("appName")));
            context.driver.FindElement(By.Name("appName")).SendKeys(context.AppName);
            context.tinyWait.Until(ExpectedConditions.ElementToBeClickable(By.CssSelector("[test-hook='apps.new-app.create']")));
            context.driver.FindElement(By.CssSelector("[test-hook='apps.new-app.create']")).Click();

            // we arrived to intern app page
            // check "next" button exist
            // thanks to shmuela

            //context.tinyWait.Until(ExpectedConditions.ElementToBeClickable(By.CssSelector("[test-hook='database-edit.create']")));
            //context.driver.FindElement(By.CssSelector("[test-hook='database-edit.create']")).Click();
            return(context);
        }
Beispiel #11
0
        public static AutomationTestContext OpenApp(this AutomationTestContext context)
        {
            try
            {
                context.longWait.Until(ExpectedConditions.ElementIsVisible(By.XPath("//*[text()[contains(.,'Manage')]]"))).Click();


                //context.longWait.Until(ExpectedConditions.ElementIsVisible(By.CssSelector("[test-hook='apps.app-panel.manage-button']"))).Click();
            }
            catch (Exception exception)
            {
                throw new ElementNotVisibleException("Element probably disappeared because app was not created and logged out", exception);
            }

            return(context);
        }
Beispiel #12
0
        private List <AppViewModel> GetAllApps(AutomationTestContext current)
        {
            List <AppViewModel> model = new List <AppViewModel>();
            var appsNames             = current.driver.FindElements(By.ClassName("body-height")).Select(a => a.Text).ToList();

            // skip first element because "add a new app" button have a ribbon
            var statuses = current.driver.FindElements(By.ClassName("ui-ribbon")).Select(a => a.Text).Skip(1).ToList();

            for (int i = 0; i < appsNames.Count(); i++)
            {
                model.Add(new AppViewModel {
                    Name = appsNames[i], Status = statuses[i]
                });
            }

            return(model);
        }
Beispiel #13
0
        public static AutomationTestContext Log(this AutomationTestContext context, Exception e = null, string freeText = null)
        {
            bool failure        = e != null;
            int  failureLogType = GetFailureLogType();
            int  successLogType = GetSuccessLogType();

            //context.logger.Log("BrowserTest", "app: " + context.AppName, "username: "******"");
            string connectionString = GetConnectionString();
            string cmd = "insert into durados_log ([ApplicationName], [Username], [MachineName], [Time], [Controller], [Action], [MethodName], [LogType], [ExceptionMessage], [Trace], [FreeText]) values (@ApplicationName, @Username, @MachineName, @Time, @Controller, @Action, @MethodName, @LogType, @ExceptionMessage, @Trace, @FreeText)";

            using (SqlConnection connection = new SqlConnection(connectionString))
            {
                connection.Open();
                using (SqlCommand command = new SqlCommand(cmd, connection))
                {
                    command.Parameters.AddWithValue("ApplicationName", context.AppName);
                    command.Parameters.AddWithValue("Username", context.username);
                    command.Parameters.AddWithValue("MachineName", System.Environment.MachineName);
                    command.Parameters.AddWithValue("Time", DateTime.Now);
                    command.Parameters.AddWithValue("Controller", "auto test");
                    command.Parameters.AddWithValue("Action", "Action");
                    command.Parameters.AddWithValue("MethodName", "MethodName");
                    command.Parameters.AddWithValue("LogType", failure ? failureLogType : successLogType);
                    command.Parameters.AddWithValue("ExceptionMessage", e == null ? string.Empty : e.Message);
                    command.Parameters.AddWithValue("Trace", e == null ? string.Empty : e.ToString());
                    command.Parameters.AddWithValue("freeText", freeText == null ? string.Empty : freeText);

                    try
                    {
                        command.ExecuteNonQuery();
                    }
                    catch (Exception exception)
                    {
                        throw exception;
                    }
                }
            }
            return(context);
        }
Beispiel #14
0
        public static AutomationTestContext LogOut(this AutomationTestContext context)
        {
            try
            {
                context.longWait.Until(ExpectedConditions.ElementIsVisible(By.CssSelector("[ng-bind='okBtnText']"))).Click();
                // wait for fadeout animation
                Thread.Sleep(1000);
            }
            catch (Exception exception)
            {
                throw new ElementNotVisibleException("Element probably disappeared because app was not created and logged out", exception);
            }



            var res = context.longWait.Until(ExpectedConditions.ElementToBeClickable(By.ClassName("dropdown-toggle")));

            if (res == null)
            {
                throw new ElementNotVisibleException("Can't find user tag");
            }
            try
            {
                // wait for fadeout animation
                Thread.Sleep(500);
                res.Click();
            }
            catch (Exception exception)
            {
                throw new ElementNotVisibleException("Element probably disappeared because app was not created and logged out", exception);
            }

            context.longWait.Until(ExpectedConditions.ElementIsVisible(By.CssSelector("[ng-click='header.logout()']"))).Click();

            return(context);
        }
Beispiel #15
0
 public static AutomationTestContext GoToAppsPage(this AutomationTestContext context)
 {
     // goto appPage
     context.driver.Navigate().GoToUrl(context.WebPage + "/#/");
     return(context);
 }
Beispiel #16
0
 public static AutomationTestContext Finish(this AutomationTestContext context)
 {
     context.driver.Dispose();
     return(context);
 }
Beispiel #17
0
 public static AutomationTestContext ClicktOnTryMeButton(this AutomationTestContext context)
 {
     return(context);
 }