Esempio n. 1
0
        public void DeleteSetting(string name)
        {
            if (this.Browser.Url != this.Url)
            {
                this.Navigate();
            }

            int settingsCount      = Pages <SettingsPage> .Instance.Map.SettingsGrid.DataItems.Count;
            int newSettingRowIndex = 0;

            for (int i = 0; i < settingsCount; i++)
            {
                bool correctRow = Pages <SettingsPage> .Instance.Map.SettingsGrid.DataItems[i][1].TextContent == name;
                if (correctRow)
                {
                    newSettingRowIndex = i;
                    break;
                }
            }

            HtmlAnchor deleteButton = Pages <SettingsPage> .Instance.Map.SettingsGrid.DataItems[newSettingRowIndex][6]
                                      .Find.AllByTagName <HtmlAnchor>("a").FirstOrDefault();
            AlertDialog confirmDeletionDialog = AlertDialog.CreateAlertDialog(Manager.Current.ActiveBrowser, DialogButton.OK);

            Manager.Current.DialogMonitor.AddDialog(confirmDeletionDialog);
            Manager.Current.DialogMonitor.Start();
            deleteButton.Click();
            confirmDeletionDialog.WaitUntilHandled();
            Manager.Current.DialogMonitor.Stop();
        }
Esempio n. 2
0
        public void VerifyDialogText_CodedStep()
        {
            ActiveBrowser.NavigateTo("http://www.w3schools.com/JS/tryit.asp?filename=tryjs_alert");



            // Click the button to fire the Alert Dialog inside the browser
            FrameInfo  myFrame     = new FrameInfo("iframeResult", "", "", 0);
            Browser    frame       = ActiveBrowser.Frames[myFrame];
            HtmlButton tryItButton = frame.Find.ByTagIndex <HtmlButton>("button", 0);

            //Console.WriteLine(tryItButton);

            Assert.IsNotNull(tryItButton);


            // Initialize custom 'Alert' dialog handler
            AlertDialog alertDialog = AlertDialog.CreateAlertDialog(ActiveBrowser, DialogButton.OK);

            Manager.DialogMonitor.Start();
            alertDialog.HandlerDelegate = MyCustomAlertHandler;
            Manager.DialogMonitor.AddDialog(alertDialog);
            tryItButton.Click();

            // Wait Until Dialog is Handled.
            alertDialog.WaitUntilHandled(20000);

            // Validate the text that was captured by the custom dialog handler
            Assert.AreEqual <string>("I am an alert box!", dialogText);
        }
        public void RemoveLatestExam()
        {
            AlertDialog confirmDeletionDialog = AlertDialog.CreateAlertDialog(Manager.Current.ActiveBrowser,
                                                                              DialogButton.OK);

            Manager.Current.DialogMonitor.AddDialog(confirmDeletionDialog);
            Manager.Current.DialogMonitor.Start();
            this.Map.DeleteTopExam.Click();
            confirmDeletionDialog.WaitUntilHandled();
            Manager.Current.DialogMonitor.Stop();
        }
        public void DoCustomDialogHandlingForBuiltInDialogs()
        {
            AlertDialog myAlertDialog = AlertDialog.CreateAlertDialog(ActiveBrowser, DialogButton.OK);

            myAlertDialog.HandlerDelegate = new DialogHandlerDelegate(MyCustomAlertHandler);

            // Add dialog to monitor and start monitoring
            Manager.DialogMonitor.AddDialog(myAlertDialog); Manager.DialogMonitor.Start();

            Actions.InvokeScript("InvokeAlert()");
        }
        public void DeleteLastFileUploaded()
        {
            this.Navigate();
            AlertDialog confirmDeletionDialog = AlertDialog.CreateAlertDialog(Manager.Current.ActiveBrowser, DialogButton.OK);

            Manager.Current.DialogMonitor.AddDialog(confirmDeletionDialog);
            Manager.Current.DialogMonitor.Start();
            this.Map.LastGridItemDelete.Click();
            confirmDeletionDialog.WaitUntilHandled();
            Manager.Current.DialogMonitor.Stop();
        }
        public void AlertDialogs()
        {
            // Add an alert dialog to monitor
            Manager.DialogMonitor.AddDialog(AlertDialog.CreateAlertDialog(ActiveBrowser, DialogButton.OK));

            // Given that there were not dialog attribute set, the manager will not start the monitoring.
            // You need to invoke the monitoring
            Manager.DialogMonitor.Start();

            // Invoke an alert dialog
            Actions.InvokeScript("InvokeAlert()");

            // The dialog will now be automatically handled transparently in the background without any help from the test code.
        }
Esempio n. 7
0
 public void AddAlertDialog()
 {
     StopAlertDialog();
     Manager.Current.DialogMonitor.AddDialog(AlertDialog.CreateAlertDialog(Manager.Current.ActiveBrowser, DialogButton.OK));
     Manager.Current.DialogMonitor.Start();
 }
Esempio n. 8
0
        public void TestMethod3()
        {
            Manager  manager;
            Settings mySettings = new Settings();

            //
            // Precondition
            //mySettings.Web.DefaultBrowser = BrowserType.FireFox;
            //mySettings.Web.DefaultBrowser = BrowserType.InternetExplorer;
            mySettings.Web.DefaultBrowser = BrowserType.Chrome;
            //mySettings.UnexpectedDialogAction = UnexpectedDialogAction.DoNotHandle;
            mySettings.UnexpectedDialogAction = UnexpectedDialogAction.HandleAndContinue;
            manager = new Manager(mySettings);
            manager.Start();
            manager.LaunchNewBrowser();
            manager.ActiveBrowser.NavigateTo("https://wow.training.local/Index#/Home");
            //
            IList <HtmlControl> description = manager.ActiveBrowser.Find.AllByXPath <HtmlControl>("//div[@class='text-primary']/h2/small");

            Console.WriteLine("description = " + description.Count);
            if ((description.Count == 0) && (manager.ActiveBrowser.BrowserType == BrowserType.Chrome))
            {
                for (int i = 0; i < 5; i++)
                {
                    manager.ActiveBrowser.Desktop.KeyBoard.KeyPress(System.Windows.Forms.Keys.Tab);
                }
                manager.ActiveBrowser.Desktop.KeyBoard.KeyPress(System.Windows.Forms.Keys.Space);
                manager.ActiveBrowser.Desktop.KeyBoard.KeyPress(System.Windows.Forms.Keys.Tab);
                manager.ActiveBrowser.Desktop.KeyBoard.KeyPress(System.Windows.Forms.Keys.Tab);
                manager.ActiveBrowser.Desktop.KeyBoard.KeyPress(System.Windows.Forms.Keys.Enter);
            }
            Thread.Sleep(1000);
            //
            //
            Manager.Current.DialogMonitor.AddDialog(AlertDialog.CreateAlertDialog(Manager.Current.ActiveBrowser, DialogButton.OK));
            Manager.Current.DialogMonitor.Start();
            //
            // Check JS injection
            Manager.Current.ActiveBrowser.Actions.InvokeScript("alert('Ha-Ha-Ha')");
            Thread.Sleep(4000);
            //string strBool = Actions.InvokeScript("Alert('Ha-Ha-Ha')");
            //
            //Manager.Current.ActiveBrowser.Actions.
            //
            //ConfirmDialog confirmDialog = ConfirmDialog.CreateConfirmDialog(Manager.Current.ActiveBrowser,DialogButton.OK);
            //confirmDialog.HandlerDelegate = new DialogHandlerDelegate(this.ConfirmHandleDialog);
            //Manager.Current.DialogMonitor.AddDialog(confirmDialog);
            //Manager.Current.DialogMonitor.Start();
            // Click the button
            //Manager.Current.ActiveBrowser.Action.MouseClickItem(RSSControls.Applications.ApplicationsEditLoginPage.DeleteQuestion);
            //confirmDialog.WaitUntilHandled();
            //Manager.Current.DialogMonitor.RemoveDialog(confirmDialog);
            //Manager.Current.DialogMonitor.Stop();
            //
            // Test Steps
            HtmlButton loginButton = manager.ActiveBrowser.Find.ByAttributes <HtmlButton>("class=btn btn-success");

            loginButton.Click();
            //HtmlInputEmail loginInput = manager.ActiveBrowser.Find.ByAttributes<HtmlInputEmail>("class=form-control ng-pristine ng-valid ng-valid-email ng-touched");
            HtmlInputEmail loginInput = manager.ActiveBrowser.Find.ByAttributes <HtmlInputEmail>("ng-model=email");

            loginInput.Text = "*****@*****.**";
            Thread.Sleep(1000);
            HtmlInputPassword passwordInput = manager.ActiveBrowser.Find.ByAttributes <HtmlInputPassword>("ng-model=password");

            passwordInput.Text = "irawow123";
            Thread.Sleep(1000);
            HtmlInputSubmit submitInput = manager.ActiveBrowser.Find.ByName <HtmlInputSubmit>("loginButton");

            submitInput.Click();
            Thread.Sleep(2000);
            //
            // Check
            HtmlSpan userAccount = manager.ActiveBrowser.Find.ByAttributes <HtmlSpan>("ng-bind=userName");

            //Console.WriteLine("HtmlSpan userAccount done");
            Assert.AreEqual("LV-204 ISTQB", userAccount.TextContent);
            //Console.WriteLine("Assert.AreEqual LV - 204 ISTQB done");
            //
            // Return to previous state
            manager.ActiveBrowser.Find.ById <HtmlDiv>("dropdownBtn").Click();
            //Console.WriteLine("dropdownBtn done");
            Thread.Sleep(2000);
            // logout
            manager.ActiveBrowser.Find.ByAttributes <HtmlAnchor>("ng-click=logOut()").Click();
            //Manager.Current.ActiveBrowser.Actions.InvokeScript("logOut();");
            Console.WriteLine("ng-click=logOut() done");
            Thread.Sleep(2000);
            //HtmlControl loginDescription = manager.ActiveBrowser.Find.ByXPath<HtmlControl>("//div[@class='text-primary']/h2/small");
            var loginDescription = manager.ActiveBrowser.Find.ByXPath("//div[@class='text-primary']/h2/small");

            Console.WriteLine("loginDescription done loginDescription.TextContent = " + loginDescription.TextContent);
            Assert.AreEqual("SoftServe Language School", loginDescription.TextContent);
            //
            manager.Dispose();
            Console.WriteLine("done");
        }