Пример #1
0
        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.AlwaysReturnFromSynchronise(element);

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

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

            RunQueryAndCheckTiming();

            Assert.That(driver.HoveredElements, Has.Member(element));
        }
Пример #2
0
        public void It_finds_then_synchronises_click_element_on_underlying_driver()
        {
            var element = new StubElement();

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

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

            elementScope.Click();

            Assert.That(driver.ClickedElements, Has.No.Member(elementScope), "Click was not synchronised");

            RunQueryAndCheckTiming();

            Assert.That(driver.ClickedElements, Has.Member(elementScope));
        }
Пример #3
0
        public void It_sends_keys_to_element_via_underlying_driver()
        {
            var element = new StubElement();

            driver.StubId("something", element, browserSession, sessionConfiguration);
            SpyTimingStrategy.AlwaysReturnFromSynchronise(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_makes_robust_call_to_find_then_clicks_element_on_underlying_driver()
        {
            var element = new StubElement();

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

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

            toCheck.Uncheck();

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

            RunQueryAndCheckTiming();

            Assert.That(driver.UncheckedElements, 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.AlwaysReturnFromSynchronise(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"));
        }
Пример #6
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 <Element>, 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.AlwaysReturnFromSynchronise(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);
        }