public void TestExecuteSuccess()
        {
            var timeout  = TimeSpan.FromMilliseconds(1);
            var propData = new Mock <IPropertyData>(MockBehavior.Strict);

            propData.Setup(p => p.WaitForElementCondition(WaitConditions.Exists, It.IsAny <TimeSpan>())).Returns(true);

            var locator = new Mock <IElementLocator>(MockBehavior.Strict);
            var expectedPropertyData = propData.Object;

            locator.Setup(p => p.TryGetElement("myproperty", out expectedPropertyData)).Returns(true);

            var waitForElementAction = new WaitForElementAction
            {
                ElementLocator = locator.Object
            };

            var context = new WaitForElementAction.WaitForElementContext("myproperty", WaitConditions.Exists, timeout);
            var result  = waitForElementAction.Execute(context);

            Assert.AreEqual(true, result.Success);

            locator.VerifyAll();
            propData.VerifyAll();
        }
        public void TestExecuteFailureIfResultIsFalse()
        {
            var timeout  = TimeSpan.FromSeconds(1);
            var propData = new Mock <IPropertyData>(MockBehavior.Strict);

            propData.Setup(p => p.WaitForElementCondition(WaitConditions.Exists, It.IsAny <TimeSpan>())).Returns(false);

            var locator = new Mock <IElementLocator>(MockBehavior.Strict);
            var expectedPropertyData = propData.Object;

            locator.Setup(p => p.TryGetElement("myproperty", out expectedPropertyData)).Returns(true);

            var waitForElementAction = new WaitForElementAction
            {
                ElementLocator = locator.Object
            };

            var context = new WaitForElementAction.WaitForElementContext("myproperty", WaitConditions.Exists, timeout);
            var result  = waitForElementAction.Execute(context);

            Assert.AreEqual(false, result.Success);
            Assert.AreEqual("Could not perform action 'BecomesExistent' before timeout: 00:00:01", result.Exception.Message);

            locator.VerifyAll();
            propData.VerifyAll();
        }
示例#3
0
        /// <summary>
        /// Calls the pipeline action.
        /// </summary>
        /// <param name="propertyName">Name of the property.</param>
        /// <param name="expectedCondition">The expected condition.</param>
        /// <param name="timeout">The timeout for waiting.</param>
        private void CallPipelineAction(string propertyName, WaitConditions expectedCondition, TimeSpan?timeout)
        {
            var page = this.GetPageFromContext();

            var context = new WaitForElementAction.WaitForElementContext(propertyName.ToLookupKey(), expectedCondition, timeout);

            this.actionPipelineService.PerformAction <WaitForElementAction>(page, context).CheckResult();
        }
        public void TestExecuteFieldDoesNotExist()
        {
            var locator = new Mock<IElementLocator>(MockBehavior.Strict);
            locator.Setup(p => p.GetElement("doesnotexist")).Throws(new ElementExecuteException("Cannot find item"));

            var buttonClickAction = new WaitForElementAction
                                        {
                                            ElementLocator = locator.Object
                                        };

            var context = new WaitForElementAction.WaitForElementContext("doesnotexist", WaitConditions.Exists, null);

            ExceptionHelper.SetupForException<ElementExecuteException>(
                () => buttonClickAction.Execute(context), e => locator.VerifyAll());
        }
示例#5
0
        public void TestExecuteFieldDoesNotExist()
        {
            var locator = new Mock <IElementLocator>(MockBehavior.Strict);

            locator.Setup(p => p.GetElement("doesnotexist")).Throws(new ElementExecuteException("Cannot find item"));

            var buttonClickAction = new WaitForElementAction
            {
                ElementLocator = locator.Object
            };

            var context = new WaitForElementAction.WaitForElementContext("doesnotexist", WaitConditions.Exists, null);

            ExceptionHelper.SetupForException <ElementExecuteException>(
                () => buttonClickAction.Execute(context), e => locator.VerifyAll());
        }
        public void TestExecuteFieldDoesNotExist()
        {
            var locator = new Mock<IElementLocator>(MockBehavior.Strict);
            IPropertyData expectedPropertyData = null;
            locator.Setup(p => p.TryGetElement("doesnotexist", out expectedPropertyData)).Returns(false);
            locator.Setup(p => p.GetElement("doesnotexist")).Throws(new ElementExecuteException("Cannot find item"));

            var buttonClickAction = new WaitForElementAction
            {
                ElementLocator = locator.Object
            };

            var context = new WaitForElementAction.WaitForElementContext("doesnotexist", WaitConditions.Exists, TimeSpan.FromMilliseconds(1));

            ExceptionHelper.SetupForException<ElementExecuteException>(
                () => buttonClickAction.Execute(context), e => locator.VerifyAll());
        }
        public void TestExecuteFieldDoesNotExist()
        {
            var           locator = new Mock <IElementLocator>(MockBehavior.Strict);
            IPropertyData expectedPropertyData = null;

            locator.Setup(p => p.TryGetElement("doesnotexist", out expectedPropertyData)).Returns(false);
            locator.Setup(p => p.GetElement("doesnotexist")).Throws(new ElementExecuteException("Cannot find item"));

            var buttonClickAction = new WaitForElementAction
            {
                ElementLocator = locator.Object
            };

            var context = new WaitForElementAction.WaitForElementContext("doesnotexist", WaitConditions.Exists, TimeSpan.FromMilliseconds(1));

            ExceptionHelper.SetupForException <ElementExecuteException>(
                () => buttonClickAction.Execute(context), e => locator.VerifyAll());
        }
        public void TestExecuteSuccess()
        {
            var timeout = TimeSpan.FromSeconds(5);
            var propData = new Mock<IPropertyData>(MockBehavior.Strict);
            propData.Setup(p => p.WaitForElementCondition(WaitConditions.Exists, timeout)).Returns(true);

            var locator = new Mock<IElementLocator>(MockBehavior.Strict);
            locator.Setup(p => p.GetElement("myproperty")).Returns(propData.Object);

            var waitForElementAction = new WaitForElementAction
            {
                ElementLocator = locator.Object
            };

            var context = new WaitForElementAction.WaitForElementContext("myproperty", WaitConditions.Exists, timeout);
            var result = waitForElementAction.Execute(context);

            Assert.AreEqual(true, result.Success);

            locator.VerifyAll();
            propData.VerifyAll();
        }
示例#9
0
        /// <summary>
        /// Calls the pipeline action.
        /// </summary>
        /// <param name="propertyName">Name of the property.</param>
        /// <param name="expectedCondition">The expected condition.</param>
        /// <param name="timeout">The timeout for waiting.</param>
        private void CallPipelineAction(string propertyName, WaitConditions expectedCondition, TimeSpan? timeout)
        {
            var page = this.GetPageFromContext();

            var context = new WaitForElementAction.WaitForElementContext(propertyName.ToLookupKey(), expectedCondition, timeout);
            this.actionPipelineService.PerformAction<WaitForElementAction>(page, context).CheckResult();
        }
        public void TestExecuteFailureIfResultIsFalse()
        {
            var timeout = TimeSpan.FromSeconds(5);
            var propData = new Mock<IPropertyData>(MockBehavior.Strict);
            propData.Setup(p => p.WaitForElementCondition(WaitConditions.Exists, timeout)).Returns(false);

            var locator = new Mock<IElementLocator>(MockBehavior.Strict);
            locator.Setup(p => p.GetElement("myproperty")).Returns(propData.Object);

            var waitForElementAction = new WaitForElementAction
            {
                ElementLocator = locator.Object
            };

            var context = new WaitForElementAction.WaitForElementContext("myproperty", WaitConditions.Exists, timeout);
            var result = waitForElementAction.Execute(context);

            Assert.AreEqual(false, result.Success);
            Assert.AreEqual("Could not perform action 'Exists' before timeout: 00:00:05", result.Exception.Message);

            locator.VerifyAll();
            propData.VerifyAll();
        }