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();
        }
        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 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());
        }
示例#4
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();
        }
        public void TestGetActionName()
        {
            var buttonClickAction = new WaitForElementAction();

            Assert.AreEqual("WaitForElementAction", buttonClickAction.Name);
        }
        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();
        }
        public void TestGetActionName()
        {
            var buttonClickAction = new WaitForElementAction();

            Assert.AreEqual("WaitForElementAction", buttonClickAction.Name);
        }