Exemplo n.º 1
0
 public void HandleAllAlertTest()
 {
     test = extent
            .StartTest("HandleAllAlertTest", "Tests page for presence of alerts")
            .AssignCategory("AllertHandling");
     try
     {
         Assert.IsTrue(AlertHandler.HandleAllAlerts(_driver, 2));
         test.Log(LogStatus.Pass, "The Handle Alerts are Present");
     }
     catch (AssertionException ex)
     {
         test.Log(LogStatus.Fail, "<pre>" + ex.StackTrace + "</pre>");
         throw;
     }
     try
     {
         Assert.IsTrue(_driver.FindElement(By.Id("button")).Enabled);
         test.Log(LogStatus.Pass, "The Button Is Present");
     }
     catch (AssertionException ex)
     {
         test.Log(LogStatus.Fail, "<pre>" + ex.StackTrace + "</pre>");
         throw;
     }
 }
Exemplo n.º 2
0
        public async Task Brand_New_Alert_Successfully_Recognized_And_Signaled()
        {
            var alertsRepositoryMock    = new AlertsRepositoryMock();
            var notificationServiceMock = new Mock <INotificationService>();
            var loggerMock = new Mock <Microsoft.Extensions.Logging.ILogger>();

            var handler  = new AlertHandler(alertsRepositoryMock, notificationServiceMock.Object, loggerMock.Object);
            var newAlert = new Alert
            {
                id             = "123",
                AlertType      = AlertTypes.ThresholdViolation,
                ApplicationUri = "SomeAppUri",
                AverageValue   = 56,
                DisplayName    = "Temperature",
                Timestamp      = DateTime.Now
            };

            await handler.HandleAsync(new List <Alert> {
                newAlert
            });

            var createdAlert = alertsRepositoryMock.All.First();

            Assert.AreEqual(1, createdAlert.Occurrences);
            Assert.AreSame(newAlert, createdAlert);
            notificationServiceMock.Verify(mock => mock.NotifyAsync(newAlert), Times.Once);
        }
        /// <summary>
        /// Delete the test. Clicking this link and Accepting the Alert can take you to different pages based on the Workflow.
        /// </summary>
        public void DeleteTest()
        {
            CurrentWindow = Driver.CurrentWindowHandle;
            Report.Write("The current window is: '" + CurrentWindow + "'.");

            DeleteTestLink.Wait(2).Click();
            AlertHandler alert = new AlertHandler();

            alert.VerifyText("Are you sure you want to delete this test?");
            alert.VerifyText("This cannot be undone.");
            alert.Accept();

            /*
             * IAlert alert = Driver.SwitchTo().Alert();
             * string expected1 = "Are you sure you want to delete this test?";
             * string expected2 = "This cannot be undone.";
             * if (Driver.GetType() == typeof (DummyDriver))
             * {
             *  ((DummyIAlert)alert).Text = expected1 + " " + expected2;
             * }
             * string actual = alert.Text;
             * Debug.WriteLine("The alert text: '" + actual + "'.");
             * Assert.IsTrue(actual.Contains(expected1), "The delete confirmation pop-up does not contain the expected text: '" + expected1 + "'; actual text: '" + actual + "'.");
             * Assert.IsTrue(actual.Contains(expected2), "The delete confirmation pop-up does not contain the expected text: '" + expected2 + "'; actual text: '" + actual + "'.");
             * alert.Accept();
             */

            //switch to window
            DriverCommands.WaitToSwitchWindow(CurrentWindow, 5);
        }
        private void VerifyPageIsActuallyLoad()
        {
            // tc 24186, bug 87479
            // Sometimes network is slow and gateway return a blank page. This page will need to be refresh
            try
            {
                Report.Write("Attempting to verified page content is actually loaded. Checking if site title exist.");
                //SiteTitleLabel = new WebElementWrapper(Driver, BySiteTitleLabel);
                //SiteTitleLabel.FindElement();
                //Make sure page is actually loaded by clicking on welcome message
                this.Utilities.FocusOnMainContentArea();//Header.SelectWelcomeMessage();
                Report.Write("Page content is loaded successfully. Got Site title.");
            }
            catch (Exception e)
            {
                if (Driver.WrappedDriver.GetType() == typeof(FirefoxDriver))
                {
                    this.CurrentWindowHandle = Driver.CurrentWindowHandle;

                    Report.Write("Page content was not loaded. Attempting to refresh the page again.");
                    Driver.Navigate().Refresh();

                    AlertHandler alert = new AlertHandler();
                    alert.VerifyText("Are you sure you wish to delete this item?");
                    alert.Accept();

                    //switch to window
                    DriverCommands.WaitToSwitchWindow(this.CurrentWindowHandle, 5);
                }//exception was not being thrown for other browsers
                else
                {
                    throw new Exception("\nInnerException:\n" + e.InnerException + "\nStackTrace:\n" + e.StackTrace, e);
                }
            }
        }
Exemplo n.º 5
0
 public Person(string name, string lastName, int age)
 {
     FirstName     = name;
     LastName      = lastName;
     Age           = age;
     Notifications = new List <Notification>();
     Alert        += OnNewNotification;
 }
Exemplo n.º 6
0
        /// <summary>
        /// register custom alert handler for site
        /// </summary>
        /// <param name="site"></param>
        private void RegisterAlertHandler(SPSite site)
        {
            DeleteTMPFile(site);
            var    alertFile = GetOrCreateDefaultAlertFile();
            string changedFile;

            AlertHandler.RegisterForAll(alertFile, out changedFile);
            site.RootWeb.Properties[TEMP_FILE] = changedFile;
            site.RootWeb.Properties.Update();
            ExecuteUpdate(site, changedFile);
        }
        /// <summary>
        /// delete
        /// </summary>
        public void SelectDelete()
        {
            string currentWindow = Driver.CurrentWindowHandle;

            Report.Write("The current window is: '" + currentWindow + "'.");
            DeleteLink.Click();

            AlertHandler alert = new AlertHandler();

            alert.VerifyText("Are you sure you want to delete this rubric? All associations to this rubric will be permanently deleted.");
            alert.Accept();

            //switch to window
            DriverCommands.WaitToSwitchWindow(currentWindow, 5);
        }
Exemplo n.º 8
0
        /// <summary>
        /// Delete the item and Accept the Alert.
        /// </summary>
        public void DeleteItem()
        {
            this.Parent.CurrentWindowHandle = Driver.CurrentWindowHandle;
            Report.Write("The current window is: '" + this.Parent.CurrentWindowHandle + "'.");

            DeleteItemButton.Wait(3).Click();

            AlertHandler alert = new AlertHandler();

            alert.VerifyText("Are you sure you wish to delete this item?");
            alert.Accept();

            //switch to window
            DriverCommands.WaitToSwitchWindow(this.Parent.CurrentWindowHandle, 5);
        }
Exemplo n.º 9
0
 public void HandleAlertTest()
 {
     test = extent
            .StartTest("HandleAlertTest", "Tests page for presence of alert")
            .AssignCategory("AllertHandling");
     try
     {
         Assert.IsTrue(AlertHandler.HandleAlert(_driver, 3));
         test.Log(LogStatus.Pass, "The Handle Alert is Present");
     }
     catch (AssertionException ex)
     {
         test.Log(LogStatus.Fail, "<pre>" + ex.StackTrace + "</pre>");
         throw;
     }
 }
        /// <summary>
        /// Delete the item and Accept the Alert.
        /// </summary>
        public void DeleteItem()
        {
            this.Parent.CurrentWindowHandle = Driver.CurrentWindowHandle;
            Report.Write("The current window is: '" + this.Parent.CurrentWindowHandle + "'.");

            Utilities.FocusOnMainContentArea(); //stop hover over menu
            Delete_Link.Wait(3).Click();

            AlertHandler alert = new AlertHandler();

            alert.VerifyText("Are you sure you wish to delete this item?");
            alert.Accept();

            //switch to window
            DriverCommands.WaitToSwitchWindow(this.Parent.CurrentWindowHandle, 5);
        }
Exemplo n.º 11
0
        static void Main(string[] args)
        {
            Console.WriteLine("Register (R) or Unregister (U) ? (R/U)");
            var mode = Console.ReadLine().ToLower();

            if (mode == "r" || mode == "u")
            {
                Console.WriteLine("IIS will be reseted and SharePoint Timer Service will be restarted. Continue? (y/n)");
                if (Console.ReadLine().ToLower() == "y")
                {
                    Console.WriteLine("Modifying alerttemplates.xml");
                    var path = SPUtility.GetGenericSetupPath(@"TEMPLATE\XML\");
                    var bin  = SPUtility.GetGenericSetupPath(@"BIN\");
                    var file = Path.Combine(path, "alerttemplates.xml");
                    if (mode == "r")
                    {
                        Console.WriteLine("registering custom AlertHandler");
                        AlertHandler.RegisterForAll(file);
                    }
                    else
                    {
                        Console.WriteLine("Unregistering custom AlertHandler");
                        AlertHandler.UnRegisterForAll(file);
                    }
                    Console.WriteLine("Updating alerts");
                    Process.Start(Path.Combine(bin, "stsadm.exe"), "-o updatealerttemplates -url http://localhost/").WaitForExit();
                    Console.WriteLine("IIS reseting");
                    Process.Start("iisreset").WaitForExit();
                    Console.WriteLine("timer restarting");
                    Process.Start("net", "stop SPTimerV4").WaitForExit();
                    Process.Start("net", "start SPTimerV4").WaitForExit();
                    Console.WriteLine("Finished");
                }
                else
                {
                    Console.WriteLine("cancelled");
                }
            }
            else
            {
                Console.WriteLine("Wrong mode");
            }

            Console.WriteLine("Any key...");
            Console.ReadKey();
        }
Exemplo n.º 12
0
        public void BeginSheet(Cocoa.Window theWindow, AlertHandler modalDelegate, System.IntPtr contextInfo)
        {
            if (modalDelegate == null)
            {
                throw new ArgumentNullException("modalDelegate");
            }
            Cocoa.Object target   = (Cocoa.Object)modalDelegate.Target;
            MethodInfo   method   = modalDelegate.Method;
            string       selector = method.Name;

            foreach (ExportAttribute export_attribute in Attribute.GetCustomAttributes(method, typeof(ExportAttribute)))
            {
                if (export_attribute.Selector != null)
                {
                    selector = export_attribute.Selector;
                }
            }
            ObjCMessaging.objc_msgSend(NativeObject, "beginSheetModalForWindow:modalDelegate:didEndSelector:contextInfo:", typeof(void), typeof(System.IntPtr), (theWindow == null) ? IntPtr.Zero : theWindow.NativeObject, typeof(System.IntPtr), target.NativeObject, typeof(System.IntPtr), ObjCMethods.sel_getUid(selector), typeof(System.IntPtr), contextInfo);
        }
Exemplo n.º 13
0
        public async Task Successfully_Recognized_That_Current_Alert_Already_Expired_New_One_Created()
        {
            const string AlertId = "123";
            var          notificationServiceMock = new Mock <INotificationService>();
            var          loggerMock           = new Mock <Microsoft.Extensions.Logging.ILogger>();
            var          alertsRepositoryMock = new AlertsRepositoryMock();

            alertsRepositoryMock.PrePopulateAlerts(new List <Alert>
            {
                new Alert
                {
                    id             = AlertId,
                    AlertType      = AlertTypes.ThresholdViolation,
                    ApplicationUri = "SomeAppUri",
                    AverageValue   = 56,
                    DisplayName    = "Temperature",
                    Timestamp      = DateTime.Now.AddMinutes(-46),
                    Occurrences    = 1
                }
            });

            var handler = new AlertHandler(alertsRepositoryMock, notificationServiceMock.Object, loggerMock.Object);

            var newAlert = new Alert
            {
                AlertType      = AlertTypes.ThresholdViolation,
                ApplicationUri = "SomeAppUri",
                AverageValue   = 56,
                DisplayName    = "Temperature",
                Timestamp      = DateTime.Now
            };

            await handler.HandleAsync(new List <Alert> {
                newAlert
            });

            var addedAlert = alertsRepositoryMock.All.Where(alert => alert.id != AlertId).Single();

            Assert.AreEqual(1, newAlert.Occurrences);
            Assert.AreEqual(2, alertsRepositoryMock.All.Count());
            notificationServiceMock.Verify(mock => mock.NotifyAsync(newAlert), Times.Once);
        }
        /// <summary>
        /// select assign to individual students
        /// </summary>
        public void SelectAssignToIndividualStudents()
        {
            AssignToIndividualStudentsRadio.Wait(3);
            AssignToIndividualStudentsRadio.Selected = true;
            if (AssignToIndividualStudentsRadio.Selected == false)
            {
                this.Parent.CurrentWindowHandle = Driver.CurrentWindowHandle;
                Report.Write("The current window is: '" + this.Parent.CurrentWindowHandle + "'.");

                AssignToIndividualStudentsRadio.Wait(3).Click();

                AlertHandler alert = new AlertHandler();
                alert.VerifyText("You will lose your selection if you change to a different assignment method?");
                alert.Accept();

                //switch to window
                DriverCommands.WaitToSwitchWindow(this.Parent.CurrentWindowHandle, 5);

                DriverCommands.WaitAndMeasurePageLoadTime();
                this.Parent.InitElements();
                Grid = new EditTeacherAssignmentGrid(assignToIndividualStudentsGrid, true, ControlPrefix);
            }
        }
        /// <summary>
        /// ready to schedule the test
        /// </summary>
        /// <returns>ViewTestDetailsPage</returns>
        public ViewTestDetailsPage ReadyToSchedule()
        {
            this.CurrentWindowHandle = Driver.CurrentWindowHandle;
            Report.Write("The current window is: '" + this.CurrentWindowHandle + "'.");

            TestStages.ReadyToSchedule();
            //Driver.AcceptAlert();

            AlertHandler alert = new AlertHandler();

            alert.VerifyText("Are you sure you are ready to schedule the test?");
            alert.VerifyText("You will no longer be able to make changes to the test.");
            alert.VerifyText("Do you want to proceed?");
            alert.Accept();

            //switch to window
            DriverCommands.WaitToSwitchWindow(this.CurrentWindowHandle, 5);

            DriverCommands.WaitAndMeasurePageLoadTime();
            //return new ViewTestDetailsPage( TestStage.ReadyToSchedule);
            Data.TestStage = TestStage.ReadyToSchedule;
            ReloadThePage();
            return(this);
        }
Exemplo n.º 16
0
 public void BeginSheet(Cocoa.Window theWindow, AlertHandler modalDelegate, System.IntPtr contextInfo)
 {
     if (modalDelegate == null)
         throw new ArgumentNullException ("modalDelegate");
     Cocoa.Object target = (Cocoa.Object) modalDelegate.Target;
     MethodInfo method = modalDelegate.Method;
     string selector = method.Name;
     foreach (ExportAttribute export_attribute in Attribute.GetCustomAttributes (method, typeof (ExportAttribute))) {
         if (export_attribute.Selector != null)
             selector = export_attribute.Selector;
     }
     ObjCMessaging.objc_msgSend (NativeObject, "beginSheetModalForWindow:modalDelegate:didEndSelector:contextInfo:", typeof (void), typeof (System.IntPtr), (theWindow == null) ? IntPtr.Zero : theWindow.NativeObject, typeof (System.IntPtr), target.NativeObject, typeof (System.IntPtr), ObjCMethods.sel_getUid (selector), typeof (System.IntPtr), contextInfo);
 }