Example #1
0
        /// <summary>
        ///     Uses the browser to execute a GET request to the specified location and validates against the specified HTTP status
        ///     code.
        /// </summary>
        /// <typeparam name="T">
        ///     The type of page to return.
        /// </typeparam>
        /// <param name="browser">
        ///     The browser.
        /// </param>
        /// <param name="location">
        ///     The location to request.
        /// </param>
        /// <param name="expectedStatusCode">
        ///     The expected HTTP status code.
        /// </param>
        /// <returns>
        ///     A <typeparamref name="T" /> value.
        /// </returns>
        /// <exception cref="System.ArgumentNullException">
        ///     The <paramref name="browser" /> parameter is <c>null</c>.
        /// </exception>
        /// <exception cref="System.ArgumentNullException">
        ///     The <paramref name="location" /> parameter is <c>null</c>.
        /// </exception>
        public static T GoTo <T>(this IBrowser browser, Uri location, HttpStatusCode expectedStatusCode)
            where T : IPage, new()
        {
            var pageFactory = new DefaultPageFactory();

            return(browser.GoTo <T>(location, expectedStatusCode, pageFactory));
        }
Example #2
0
        public void Setup()
        {
            string url = ConfigurationSettings.AppSettings["DefaultPageUrl"] + Url;

            _browser = SetupTests._browser;
            _browser.GoTo(url);
        }
Example #3
0
        /// <summary>
        ///     Uses the browser to execute a GET request to the specified location and validates against the specified HTTP status
        ///     code.
        /// </summary>
        /// <param name="browser">
        ///     The browser.
        /// </param>
        /// <param name="location">
        ///     The location to request.
        /// </param>
        /// <param name="expectedStatusCode">
        ///     The expected HTTP status code.
        /// </param>
        /// <returns>
        ///     An <see cref="IPage" /> value.
        /// </returns>
        /// <exception cref="System.ArgumentNullException">
        ///     The <paramref name="browser" /> parameter is <c>null</c>.
        /// </exception>
        /// <exception cref="System.ArgumentNullException">
        ///     The <paramref name="location" /> parameter is <c>null</c>.
        /// </exception>
        public static dynamic GoTo(this IBrowser browser, Uri location, HttpStatusCode expectedStatusCode)
        {
            var pageFactory = new DefaultPageFactory();

            var dynamicPage = browser.GoTo <DynamicResolverPage>(location, expectedStatusCode, pageFactory);

            return(dynamicPage.ResolvedPage);
        }
Example #4
0
        public void GoToThrowsExceptionWithNullBrowserTest()
        {
            IBrowser target   = null;
            var      location = new Uri("https://google.com");

            Action action = () => target.GoTo(location);

            action.ShouldThrow <ArgumentNullException>();
        }
Example #5
0
        public void SetUp()
        {
            platform = (Platform)Enum.Parse(typeof(Platform), System.Configuration.ConfigurationManager.AppSettings["Platform"]);
            targetHost = System.Configuration.ConfigurationManager.AppSettings["TargetHost"];

            switch (platform)
            {
                case Platform.IE:

                    browser = new IE();
                    browser.ShowWindow(NativeMethods.WindowShowStyle.Maximize);
                    break;
                case Platform.FF:
                    browser = BrowserFactory.Create(BrowserType.FireFox);
                    browser.ShowWindow(NativeMethods.WindowShowStyle.Maximize);
                    break;

            }
            browser.GoTo(targetHost);
        }
Example #6
0
        /// <summary>
        ///     Uses the browser to execute a GET request to the location specified by
        ///     <see cref="IPage.TargetLocation">T.TargetLocation</see>.
        /// </summary>
        /// <param name="browser">
        ///     The browser.
        /// </param>
        /// <typeparam name="T">
        ///     The type of page to return.
        /// </typeparam>
        /// <returns>
        ///     A <typeparamref name="T" /> value.
        /// </returns>
        /// <exception cref="System.ArgumentNullException">
        ///     The <paramref name="browser" /> parameter is <c>null</c>.
        /// </exception>
        public static T GoTo <T>(this IBrowser browser) where T : IPage, new()
        {
            var page = new T();

            return(browser.GoTo <T>(page.TargetLocation, HttpStatusCode.OK));
        }
Example #7
0
 /// <summary>
 ///     Uses the browser to execute a GET request to the specified location.
 /// </summary>
 /// <param name="browser">
 ///     The browser.
 /// </param>
 /// <param name="location">
 ///     The location to request.
 /// </param>
 /// <returns>
 ///     An <see cref="IPage" /> value.
 /// </returns>
 /// <exception cref="System.ArgumentNullException">
 ///     The <paramref name="browser" /> parameter is <c>null</c>.
 /// </exception>
 /// <exception cref="System.ArgumentNullException">
 ///     The <paramref name="location" /> parameter is <c>null</c>.
 /// </exception>
 public static dynamic GoTo(this IBrowser browser, Uri location)
 {
     return(browser.GoTo(location, HttpStatusCode.OK));
 }
Example #8
0
 /// <summary>
 ///     Uses the browser to execute a GET request to the specified location.
 /// </summary>
 /// <typeparam name="T">
 ///     The type of page to return.
 /// </typeparam>
 /// <param name="browser">
 ///     The browser.
 /// </param>
 /// <param name="location">
 ///     The location to request.
 /// </param>
 /// <returns>
 ///     A <typeparamref name="T" /> value.
 /// </returns>
 /// <exception cref="System.ArgumentNullException">
 ///     The <paramref name="browser" /> parameter is <c>null</c>.
 /// </exception>
 /// <exception cref="System.ArgumentNullException">
 ///     The <paramref name="location" /> parameter is <c>null</c>.
 /// </exception>
 public static T GoTo <T>(this IBrowser browser, Uri location) where T : IPage, new()
 {
     return(browser.GoTo <T>(location, HttpStatusCode.OK));
 }
 public void GoTo(string url)
 {
     _browser.GoTo(url);
 }
Example #10
0
 public void GoTo(Uri url)
 {
     browser.GoTo(url);
 }
        public void Run(IBrowser browser)
        {
            using (browser)
            {
                foreach (Command command in commands)
                {
                    bool result = false;
                    switch (command.Action)
                    {
                    case "open":
                    {
                        string url = string.Format("{0}{1}.aspx", FairyTalesUrl, command.Subject);

                        browser.GoTo(url);
                        result = browser.Url == url;
                    }
                    break;

                    case "check":
                    {
                        if (command.Subject == "ActiveProject")
                        {
                            ISpan span = browser.Span("ctl00_ContentPlaceHolder1_activeProject");
                            if (span.Exists)
                            {
                                result = span.Text == command.Argument.Replace("\"", "");
                            }
                        }
                    }
                    break;

                    case "enter":
                    {
                        if (command.Subject == "ProjectInput")
                        {
                            string     input        = command.Argument.Replace("\"", "");
                            ITextField projectInput = browser.TextField("ctl00_ContentPlaceHolder1_projectInput");
                            if (projectInput.Exists)
                            {
                                projectInput.Value = input;
                                result             = projectInput.Value == input;
                            }
                        }
                    }
                    break;

                    case "press":
                    {
                        if (command.Subject == "AddProject")
                        {
                            IButton button = browser.Button("ctl00_ContentPlaceHolder1_addProjectButton");
                            if (button.Exists)
                            {
                                button.Click();
                                result = true;
                            }
                        }
                    }
                    break;
                    }
                    results.Add(command.ToString(), result);
                }
            }
            results["close"] = true;
        }