public UnspecifiedPageObject SelectOption(int index, IWebTestActionOptions actionOptions)
            {
                var scope =
                    _controlObject.Scope.FindTagWithAttribute("span", DiagnosticMetadataAttributes.IndexInCollection, index.ToString()).FindCss("input");

                return(CheckScope(scope, actionOptions));
            }
Exemplo n.º 2
0
        private void ClickNode(IWebTestActionOptions actionOptions)
        {
            var          actualCompletionDetector = MergeWithDefaultActionOptions(Scope, actionOptions);
            const string nodeClickScopeXpath      = "./tbody/tr/td[a[contains(@onclick, 'TreeView_SelectNode')]][last()]/a[last()]";

            new ClickAction(this, Scope.FindXPath(nodeClickScopeXpath)).Execute(actualCompletionDetector);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Executes the action using the given <paramref name="options"/>. This method blocks until the action is completed (i.e. all triggered
        /// partial and/or full page reloads are finished).
        /// </summary>
        /// <param name="options">See <see cref="IWebTestActionOptions"/> for more information.</param>
        public void Execute([NotNull] IWebTestActionOptions options)
        {
            ArgumentUtility.CheckNotNull("options", options);

            _actionID = WebTestActionSequenceNumberGenerator.GetNextSequenceNumber();
            var completionDetectionStrategy = options.CompletionDetectionStrategy ?? new NullCompletionDetectionStrategy();
            var modalDialogHandler          = options.ModalDialogHandler;
            var pageObjectContext           = _control.Context.PageObject.Context;

            OutputDebugMessage("Started.");

            OutputDebugMessage("Collecting state for completion detection...");
            var state = completionDetectionStrategy.PrepareWaitForCompletion(pageObjectContext);

            OutputDebugMessage(string.Format("Performing '{0}'...", ActionName));
            ExecuteInteraction(_scope);

            if (modalDialogHandler != null)
            {
                OutputDebugMessage("Handling modal dialog...");
                modalDialogHandler.HandleModalDialog(pageObjectContext);
            }

            OutputDebugMessage("Waiting for completion...");
            completionDetectionStrategy.WaitForCompletion(pageObjectContext, state);

            OutputDebugMessage("Finished.");
        }
        private UnspecifiedPageObject ClickItem(ElementScope itemScope, IWebTestActionOptions actionOptions)
        {
            var itemCommandScope = itemScope.FindLink();
            var itemCommand      = new CommandControlObject(Context.CloneForControl(itemCommandScope));

            return(itemCommand.Click(actionOptions));
        }
Exemplo n.º 5
0
        private UnspecifiedPageObject SwitchTo(ElementScope tabScope, IWebTestActionOptions actionOptions)
        {
            var tabCommandScope = tabScope.FindLink();
            var tabCommand      = new CommandControlObject(Context.CloneForControl(tabCommandScope));

            return(tabCommand.Click(actionOptions));
        }
        /// <inheritdoc/>
        public UnspecifiedPageObject Click(IWebTestActionOptions actionOptions = null)
        {
            var actualActionOptions = MergeWithDefaultActionOptions(Scope, actionOptions);

            new ClickAction(this, Scope).Execute(actualActionOptions);
            return(UnspecifiedPage());
        }
Exemplo n.º 7
0
        /// <summary>
        /// Unchecks the node's checkbox.
        /// </summary>
        public UnspecifiedPageObject Uncheck([CanBeNull] IWebTestActionOptions actionOptions = null)
        {
            var actualCompletionDetector = actionOptions ?? Opt.ContinueImmediately();

            new UncheckAction(this, GetCheckboxScope()).Execute(actualCompletionDetector);
            return(UnspecifiedPage());
        }
        private void ClickNode(IWebTestActionOptions actionOptions)
        {
            var selectAnchorScope = GetWellKnownSelectAnchorScope();

            var actualCompletionDetector = MergeWithDefaultActionOptions(selectAnchorScope, actionOptions);

            new ClickAction(this, selectAnchorScope).Execute(actualCompletionDetector);
        }
            public UnspecifiedPageObject SelectOptionByText(string text, IWebTestActionOptions actionOptions)
            {
                ArgumentUtility.CheckNotNull("text", text);

                var scope = _controlObject.Scope.FindTagWithAttribute("span", DiagnosticMetadataAttributes.Content, text).FindCss("input");

                return(CheckScope(scope, actionOptions));
            }
            public UnspecifiedPageObject SelectOption(string itemID, IWebTestActionOptions actionOptions)
            {
                ArgumentUtility.CheckNotNull("itemID", itemID);

                var scope = _controlObject.Scope.FindTagWithAttribute("span", DiagnosticMetadataAttributes.ItemID, itemID).FindCss("input");

                return(CheckScope(scope, actionOptions));
            }
            public UnspecifiedPageObject SelectOptionByText(string text, IWebTestActionOptions actionOptions)
            {
                ArgumentUtility.CheckNotNull("text", text);

                Action <ElementScope> selectAction = s => s.SelectOption(text);

                return(SelectOption(selectAction, actionOptions));
            }
            public UnspecifiedPageObject SelectOption(string itemID, IWebTestActionOptions actionOptions)
            {
                ArgumentUtility.CheckNotNull("itemID", itemID);

                Action <ElementScope> selectAction = s => s.SelectOptionByValue(itemID);

                return(SelectOption(selectAction, actionOptions));
            }
Exemplo n.º 13
0
        /// <inheritdoc/>
        UnspecifiedPageObject IFluentControlObjectWithTabs.WithItemID(string itemID, IWebTestActionOptions actionOptions)
        {
            ArgumentUtility.CheckNotNullOrEmpty("itemID", itemID);

            var itemScope = Scope.FindTagWithAttribute("span.tabStripTab", DiagnosticMetadataAttributes.ItemID, itemID);

            return(SwitchTo(itemScope, actionOptions));
        }
Exemplo n.º 14
0
        /// <inheritdoc/>
        UnspecifiedPageObject IFluentControlObjectWithTabs.WithHtmlID(string htmlID, IWebTestActionOptions actionOptions)
        {
            ArgumentUtility.CheckNotNullOrEmpty("htmlID", htmlID);

            var itemScope = Scope.FindId(htmlID);

            return(SwitchTo(itemScope, actionOptions));
        }
            private UnspecifiedPageObject CheckScope([NotNull] ElementScope scope, IWebTestActionOptions actionOptions)
            {
                ArgumentUtility.CheckNotNull("scope", scope);

                var actualActionOptions = _controlObject.MergeWithDefaultActionOptions(_controlObject.Scope, actionOptions);

                new CheckAction(_controlObject, scope).Execute(actualActionOptions);
                return(_controlObject.UnspecifiedPage());
            }
        /// <summary>
        /// Calls <see cref="FillWith(string,FinishInputWithAction,IWebTestActionOptions)"/> by joining the given lines with new line
        /// characters.
        /// </summary>
        public UnspecifiedPageObject FillWith(
            [NotNull] string[] lines,
            FinishInputWithAction finishInputWith,
            IWebTestActionOptions actionOptions = null)
        {
            ArgumentUtility.CheckNotNull("lines", lines);

            return(FillWith(string.Join(Environment.NewLine, lines), finishInputWith, actionOptions));
        }
 /// <summary>
 /// Sets the date component and the time component of the control to <paramref name="newDateTime"/>.
 /// </summary>
 public UnspecifiedPageObject SetDateTime(DateTime newDateTime, [CanBeNull] IWebTestActionOptions actionOptions = null)
 {
     SetDate(newDateTime, actionOptions);
     if (_hasTimeField)
     {
         SetTime(newDateTime.TimeOfDay, actionOptions);
     }
     return(UnspecifiedPage());
 }
Exemplo n.º 18
0
        private UnspecifiedPageObject ClickItem(ElementScope item, IWebTestActionOptions actionOptions)
        {
            var actualActionOptions = MergeWithDefaultActionOptions(item, actionOptions);

            var anchorScope = item.FindLink();

            new ClickAction(this, anchorScope).Execute(actualActionOptions);
            return(UnspecifiedPage());
        }
Exemplo n.º 19
0
        /// <inheritdoc/>
        UnspecifiedPageObject IFluentControlObjectWithTabs.WithIndex(int index, IWebTestActionOptions actionOptions)
        {
            var xPathSelector = string.Format(
                "(.//span{0})[{1}]",
                XPathUtils.CreateHasOneOfClassesCheck("tabStripTab", "tabStripTabSelected"),
                index);
            var itemScope = Scope.FindXPath(xPathSelector);

            return(SwitchTo(itemScope, actionOptions));
        }
        private static UnspecifiedPageObject SelectMenuOrSubMenuItem(
            ControlObjectContext context,
            ElementScope menuItemScope,
            IWebTestActionOptions actionOptions)
        {
            var menuItemCommandScope = menuItemScope.FindLink();
            var menuItemCommand      = new CommandControlObject(context.CloneForControl(menuItemCommandScope));

            return(menuItemCommand.Click(actionOptions));
        }
Exemplo n.º 21
0
        /// <summary>
        /// Expands the node.
        /// </summary>
        public TreeViewNodeControlObject Expand([CanBeNull] IWebTestActionOptions actionOptions = null)
        {
            var actualCompletionDetector = MergeWithDefaultActionOptions(Scope, actionOptions);

            const string xpath           = "./tbody/tr/td/a[contains(@href,\"','t\")]";
            var          expandLinkScope = Scope.FindXPath(xpath);

            new SimpleClickAction(this, expandLinkScope).Execute(actualCompletionDetector);
            return(this);
        }
        /// <summary>
        /// Sets the date component of the control to <paramref name="newDateString"/>.
        /// </summary>
        public UnspecifiedPageObject SetDate([NotNull] string newDateString, [CanBeNull] IWebTestActionOptions actionOptions = null)
        {
            ArgumentUtility.CheckNotNull("newDateString", newDateString);

            var dateScope = GetDateScope();

            var actualActionOptions = MergeWithDefaultActionOptions(dateScope, actionOptions);

            new FillWithAction(this, dateScope, newDateString, FinishInput.WithTab).Execute(actualActionOptions);
            return(UnspecifiedPage());
        }
        /// <inheritdoc/>
        UnspecifiedPageObject IFluentControlObjectWithSelectableItems.WithDisplayTextContains(
            string containsDisplayText,
            IWebTestActionOptions actionOptions)
        {
            ArgumentUtility.CheckNotNullOrEmpty("containsDisplayText", containsDisplayText);

            var menuItemScope = GetMainMenuScope()
                                .FindTagWithAttributeUsingOperator("span", CssComparisonOperator.SubstringMatch, DiagnosticMetadataAttributes.Content, containsDisplayText);

            return(SelectMenuOrSubMenuItem(Context, menuItemScope, actionOptions));
        }
Exemplo n.º 24
0
        private IWebTestActionOptions MergeWithDefaultActionOptions(
            IWebTestActionOptions userDefinedActionOptions,
            FinishInputWithAction finishInputWith)
        {
            if (finishInputWith == FinishInput.Promptly)
            {
                userDefinedActionOptions = userDefinedActionOptions ?? new WebTestActionOptions();
                userDefinedActionOptions.CompletionDetectionStrategy = Continue.Immediately;
            }

            return(MergeWithDefaultActionOptions(Scope, userDefinedActionOptions));
        }
        private UnspecifiedPageObject Click(int numberOfClicks, IWebTestActionOptions actionOptions)
        {
            var linkScope = Scope.FindChild("DisplayValue");

            for (var i = 0; i < numberOfClicks; ++i)
            {
                var actualActionOptions = MergeWithDefaultActionOptions(Scope, actionOptions);
                new ClickAction(this, linkScope).Execute(actualActionOptions);
            }

            return(UnspecifiedPage());
        }
Exemplo n.º 26
0
        /// <summary>
        /// Merges the <paramref name="userDefinedWebTestActionOptions"/> with the given <paramref name="scope"/>'s default
        /// <see cref="IWebTestActionOptions"/>.
        /// </summary>
        /// <param name="scope">The <see cref="ElementScope"/> with which the subsequent action is going to interact.</param>
        /// <param name="userDefinedWebTestActionOptions">User-defined <see cref="IWebTestActionOptions"/>.</param>
        protected IWebTestActionOptions MergeWithDefaultActionOptions(
            [NotNull] ElementScope scope,
            [CanBeNull] IWebTestActionOptions userDefinedWebTestActionOptions)
        {
            ArgumentUtility.CheckNotNull("scope", scope);

            if (userDefinedWebTestActionOptions == null) // prevent complicated null handling
            {
                userDefinedWebTestActionOptions = new WebTestActionOptions();
            }

            return(new WebTestActionOptions
            {
                CompletionDetectionStrategy =
                    userDefinedWebTestActionOptions.CompletionDetectionStrategy ?? GetDefaultCompletionDetectionStrategy(scope),
                ModalDialogHandler = userDefinedWebTestActionOptions.ModalDialogHandler
            });
        }
        /// <summary>
        /// Sets the time component of the control to <paramref name="newTime"/>.
        /// </summary>
        public UnspecifiedPageObject SetTime(TimeSpan newTime, [CanBeNull] IWebTestActionOptions actionOptions = null)
        {
            var newTimeAsDateTime = DateTime.MinValue.Add(newTime);

            string newTimeString;

            var timeScope = GetTimeScope();

            if (timeScope[DiagnosticMetadataAttributesForObjectBinding.BocDateTimeValueTimeFieldHasSeconds] == "true")
            {
                newTimeString = newTimeAsDateTime.ToLongTimeString();
            }
            else
            {
                newTimeString = newTimeAsDateTime.ToShortTimeString();
            }

            return(SetTime(newTimeString, actionOptions));
        }
Exemplo n.º 28
0
        /// <summary>
        /// Sets the state of the <see cref="T:Remotion.ObjectBinding.Web.UI.Controls.BocCheckBox"/> to <paramref name="newState"/>.
        /// </summary>
        public UnspecifiedPageObject SetTo(bool newState, [CanBeNull] IWebTestActionOptions actionOptions = null)
        {
            if (GetState() == newState)
            {
                return(UnspecifiedPage());
            }

            var actualActionOptions = MergeWithDefaultActionOptions(Scope, actionOptions);

            if (newState)
            {
                new CheckAction(this, Scope.FindChild("Value")).Execute(actualActionOptions);
            }
            else
            {
                new UncheckAction(this, Scope.FindChild("Value")).Execute(actualActionOptions);
            }

            return(UnspecifiedPage());
        }
        /// <summary>
        /// Sets the state of the <see cref="T:Remotion.ObjectBinding.Web.UI.Controls.BocBooleanValue"/> to <paramref name="newState"/>.
        /// </summary>
        public UnspecifiedPageObject SetTo(bool?newState, [CanBeNull] IWebTestActionOptions actionOptions = null)
        {
            if (!IsTriState() && !newState.HasValue)
            {
                throw new ArgumentException("Must not be null for non-tri-state BocBooleanValue controls.", "newState");
            }

            if (GetState() == newState)
            {
                return(UnspecifiedPage());
            }

            if (!IsTriState())
            {
                return(Click(1, actionOptions));
            }

            var states         = new bool?[] { false, null, true, false, null };
            var numberOfClicks = Array.LastIndexOf(states, newState) - Array.IndexOf(states, GetState());

            return(Click(numberOfClicks, actionOptions));
        }
        /// <inheritdoc/>
        UnspecifiedPageObject IFluentControlObjectWithSelectableItems.WithHtmlID(string htmlID, IWebTestActionOptions actionOptions)
        {
            ArgumentUtility.CheckNotNullOrEmpty("htmlID", htmlID);

            var menuItemScope = Scope.FindId(htmlID);

            return(SelectMenuOrSubMenuItem(Context, menuItemScope, actionOptions));
        }