public void It_makes_robust_call_to_find_then_hover_element_on_underlying_driver()
        {
            var element = new StubElement();

            driver.StubId("something_to_hover", element, browserSession, sessionConfiguration);
            SpyTimingStrategy.AlwaysReturnFromRobustly(element);

            browserSession.FindId("something_to_hover").Hover();

            Assert.That(driver.HoveredElements, Has.No.Member(element));

            RunQueryAndCheckTiming();

            Assert.That(driver.HoveredElements, Has.Member(element));
        }
Beispiel #2
0
        public void It_sends_keys_to_element_via_underlying_driver()
        {
            var element = new StubElement();

            driver.StubId("something", element, browserSession, sessionConfiguration);
            SpyTimingStrategy.AlwaysReturnFromRobustly(element);

            browserSession.FindId("something")
            .SendKeys("some keys to press");

            Assert.That(driver.SentKeys.Count, Is.EqualTo(0));

            RunQueryAndCheckTiming();

            Assert.That(driver.SentKeys.Count, Is.EqualTo(1));
            Assert.That(driver.SentKeys[element], Is.EqualTo("some keys to press"));
        }
        public void It_finds_then_synchronises_check_element_on_underlying_driver()
        {
            var element = new StubElement();

            driver.StubId("something_to_click", element, browserSession, sessionConfiguration);
            SpyTimingStrategy.AlwaysReturnFromRobustly(element);

            var toCheck = browserSession.FindCss("something_to_click");

            toCheck.Check();

            Assert.That(driver.CheckedElements, Has.No.Member(toCheck), "Check was not synchronised");

            RunQueryAndCheckTiming();

            Assert.That(driver.CheckedElements, Has.Member(toCheck));
        }
        public void It_makes_robust_call_to_find_then_clicks_element_on_underlying_driver()
        {
            var element = new StubElement();

            driver.StubId("something_to_fill_in", element, browserSession, sessionConfiguration);
            SpyTimingStrategy.AlwaysReturnFromRobustly(element);

            var elementScope = browserSession.FindId("something_to_fill_in");

            elementScope.FillInWith("some filled in stuff");

            Assert.That(driver.SetFields.Keys, Has.No.Member(elementScope));

            RunQueryAndCheckTiming();

            Assert.That(driver.SetFields.Keys, Has.Member(elementScope));
            Assert.That(driver.SetFields[elementScope].Value, Is.EqualTo("some filled in stuff"));
        }
Beispiel #5
0
        protected void Should_test_predicate_against_query_results_and_retry_on_failure(Func <string, Func <IEnumerable <SnapshotElementScope>, bool>, Options, IEnumerable <SnapshotElementScope> > subject, Action <string, IEnumerable <ElementFound>, Scope, Options> stub)
        {
            var locator = "Find me " + DateTime.Now.Ticks;

            var individualTimeout = TimeSpan.FromMilliseconds(DateTime.UtcNow.Millisecond);

            var expectedImmediateResult = new[] { new StubElement(), new StubElement() };
            var expectedDeferredResult  = new[] { new StubElement(), new StubElement() };

            var options = new Options {
                Timeout = individualTimeout
            };

            SpyTimingStrategy.AlwaysReturnFromRobustly(expectedImmediateResult.Select(e => new SnapshotElementScope(e, browserSession, options)));

            stub(locator, expectedDeferredResult, browserSession, options);

            VerifyFoundRobustly(subject, 0, locator, (elements) => true, expectedDeferredResult, expectedImmediateResult, options);
            VerifyFoundRobustlyAndThrows <MissingHtmlException>(subject, 1, locator, (elements) => false, null, expectedImmediateResult, options);
            VerifyFoundRobustlyAndThrows <TestException>(subject, 2, locator, (elements) => { throw new TestException("Thrown in FindAll predicate"); }, null, expectedImmediateResult, options);
        }
Beispiel #6
0
        private void Finds_element_robustly_and_returns_property_value <T>(T testValue, Action <StubElement, T> stubProperty, Func <ElementScope, T> getProperty, Func <object, Constraint> constraint = null)
        {
            constraint = constraint ?? Is.SameAs;
            var stubElement = new StubElement();

            stubProperty(stubElement, testValue);

            driver.StubId("some-element", stubElement, browserSession, sessionConfiguration);

            SpyTimingStrategy.AlwaysReturnFromRobustly(stubElement);

            if (typeof(T) == typeof(bool))
            {
                Assert.That(getProperty(browserSession.FindId("some-element")), constraint(testValue));
            }
            else
            {
                Assert.That(getProperty(browserSession.FindId("some-element")), constraint(testValue));
            }

            var queryResult = RunQueryAndCheckTiming();

            Assert.That(queryResult, Is.SameAs(stubElement));
        }