protected void Should_find_robustly(Func <string, Options, Scope> subject, Func <string, Options, Scope> scope, Action <string, ElementFound, Scope> stub) { var locator = "Find me " + DateTime.Now.Ticks; var individualTimeout = TimeSpan.FromMilliseconds(DateTime.UtcNow.Millisecond); var expectedImmediateResult = new StubElement(); var expectedDeferredResult = new StubElement(); spyRobustWrapper.AlwaysReturnFromRobustly(expectedImmediateResult); stub(locator, expectedDeferredResult, browserSession); stub(locator, expectedDeferredResult, elementScope); var options = new Options { Timeout = individualTimeout }; VerifyFoundRobustly(subject, 0, locator, expectedDeferredResult, expectedImmediateResult, options); if (scope != null) { VerifyFoundRobustly(scope, 1, locator, expectedDeferredResult, expectedImmediateResult, options); } }
private StubElement StubLinkToBeClicked(string someLinkLocator) { var linkToBeClicked = new StubElement(); linkToBeClicked.SetId(Guid.NewGuid().ToString()); driver.StubLink(someLinkLocator, linkToBeClicked); return(linkToBeClicked); }
private StubElement StubButtonToBeClicked(string locator) { var buttonToBeClicked = new StubElement(); buttonToBeClicked.SetId(Guid.NewGuid().ToString()); driver.StubButton(locator, buttonToBeClicked); return(buttonToBeClicked); }
public void It_clears_the_scope_after_executing_function() { var expectedScope = new StubElement(); session.Within(() => expectedScope, () => new object()); Assert.That(driver.Scope, Is.Null); }
private StubElement StubButtonToBeClicked(string locator) { var buttonToBeClicked = new StubElement { Id = Guid.NewGuid().ToString() }; driver.StubButton(locator, buttonToBeClicked, browserSession); return(buttonToBeClicked); }
private StubElement StubLinkToBeClicked(string someLinkLocator) { var linkToBeClicked = new StubElement { Id = Guid.NewGuid().ToString() }; driver.StubLink(someLinkLocator, linkToBeClicked, browserSession); return(linkToBeClicked); }
private StubElement StubLinkToBeClicked(string locator, Options options = null) { var linkToBeClicked = new StubElement { Id = Guid.NewGuid().ToString() }; var linkXPath = new Html(sessionConfiguration.Browser.UppercaseTagNames).Link(locator, options ?? sessionConfiguration); driver.StubAllXPath(linkXPath, new[] { linkToBeClicked }, browserSession, options ?? sessionConfiguration); return(linkToBeClicked); }
public void FindCss_with_exact_text_should_make_robust_call_to_underlying_driver() { var stubCssResult = new StubElement(); Should_find_robustly(browserSession.FindCss, elementScope.FindCss, driver.StubCss, input: "some text", matchingPattern: new Regex("^some\\ text$", RegexOptions.Multiline), expectedDeferredResult: stubCssResult, expectedImmediateResult: new StubElement(), stubCssResult: stubCssResult); }
public void FindCss_with_exact_text_should_excape_regex_chars() { var stubCssResult = new StubElement(); Should_find_robustly(browserSession.FindCss, elementScope.FindCss, driver.StubCss, input: "some (text) *", matchingPattern: new Regex("^some\\ \\(text\\)\\ \\*$", RegexOptions.Multiline), expectedDeferredResult: stubCssResult, expectedImmediateResult: new StubElement(), stubCssResult: stubCssResult); }
public void It_clears_the_scope_after_exception_in_function() { var expectedScope = new StubElement(); Assert.Throws <ExplicitlyThrownTestException>( () => session.Within <object>( () => expectedScope, () => { throw new ExplicitlyThrownTestException("Exception from action within scope"); })); Assert.That(driver.Scope, Is.Null); }
private StubElement StubField(string locator, Options options = null) { var stubField = new StubElement { Id = Guid.NewGuid().ToString() }; var fieldXpath = new Html(sessionConfiguration.Browser.UppercaseTagNames).Field(locator, options ?? sessionConfiguration); driver.StubAllXPath(fieldXpath, new [] { stubField }, browserSession, options ?? sessionConfiguration); return(stubField); }
public void It_clears_the_scope_after_executing_action() { const string locator = "Fieldset locator"; var fieldset = new StubElement(); driver.StubFieldset(locator, fieldset); session.WithinFieldset(locator, () => {}); Assert.That(driver.Scope, Is.Null); }
public void It_clears_the_scope_after_executing_action() { const string locator = "Section locator"; var section = new StubElement(); driver.StubSection(locator, section); session.WithinSection(locator, () => {}); Assert.That(driver.Scope, Is.Null); }
public void It_sets_the_scope_before_executing_action() { var expectedScope = new StubElement(); Element actualScope = null; session.Within(() => expectedScope, () => { actualScope = driver.Scope; }); Assert.That(actualScope, Is.SameAs(expectedScope)); }
public void It_makes_robust_call_to_underlying_driver() { var element = new StubElement(); session.Click(element); Assert.That(driver.ClickedElements, Is.Empty); spyRobustWrapper.DeferredActions.Single()(); Assert.That(driver.ClickedElements, Has.Member(element)); }
public void FindCss_with_regex_should_make_robust_call_to_underlying_driver() { var input = new Regex("some.*text$"); var stubCssResult = new StubElement(); Should_find_robustly(browserSession.FindCss, elementScope.FindCss, driver.StubCss, input: input, matchingPattern: input, expectedDeferredResult: stubCssResult, expectedImmediateResult: new StubElement(), stubCssResult: stubCssResult); }
public void It_clears_the_scope_after_executing_action() { const string locator = "IFrame locator"; var iframe = new StubElement(); driver.StubIFrame(locator, iframe); session.WithinIFrame(locator, () => {}); Assert.That(driver.Scope, Is.Null); }
public void When_filling_in_a_field_It_doesnt_click_to_ensure_focus_by_default() { var element = new StubElement(); driver.StubField("Some field locator", element, browserSession); browserSession.FillIn("Some field locator").With("some value for the field"); RunQueryAndCheckTiming(); Assert.That(driver.ClickedElements, Is.Empty); }
public void When_filling_in_a_field_It_clicks_to_ensure_focus() { var element = new StubElement(); driver.StubField("Some field locator", element); session.FillIn("Some field locator").With("some value for the field"); Assert.That(driver.ClickedElements, Is.Empty); spyRobustWrapper.DeferredActions.Single()(); Assert.That(driver.ClickedElements, Has.Member(element)); }
public void When_filling_in_an_field_already_found_It_sets_value_robustly() { var element = new StubElement(); session.FillIn(element).With("some value for the field"); Assert.That(driver.SetFields, Has.No.Member(element)); spyRobustWrapper.DeferredActions.Single()(); Assert.That(driver.SetFields.Keys, Has.Member(element)); Assert.That(driver.SetFields[element], Is.EqualTo("some value for the field")); }
public void It_returns_through_within_individual_timeout() { var spyRobustWrapper = new SpyRobustWrapper(); var expectedElement = new StubElement(); spyRobustWrapper.AlwaysReturnFromRobustly(expectedElement); var session = new Session(null, spyRobustWrapper, null, null, null); var actualElement = session.FindLink("bob").WithTimeout(TimeSpan.FromSeconds(321)).Now(); Assert.That(actualElement, Is.SameAs(expectedElement)); }
public void When_filling_in_an_field_already_found_It_sets_value_robustly() { var element = new StubElement(); browserSession.FillIn(element).With("some value for the field"); Assert.That(driver.SetFields, Has.No.Member(element)); RunQueryAndCheckTiming(); Assert.That(driver.SetFields.Keys, Has.Member(element)); Assert.That(driver.SetFields[element].Value, Is.EqualTo("some value for the field")); }
public void When_filling_in_file_field_It_doesnt_click() { var element = new StubElement(); element.StubAttribute("type", "file"); driver.StubField("Some field locator", element, browserSession); browserSession.FillIn("Some field locator").With("some value for the field"); RunQueryAndCheckTiming(); Assert.That(driver.ClickedElements, Has.No.Member(element)); }
public void When_choosing_a_radio_button_It_finds_field_and_chooses_robustly() { var element = new StubElement(); driver.StubField("Some radio locator", element, browserSession); browserSession.Choose("Some radio locator"); Assert.That(driver.ChosenElements, Has.No.Member(element)); RunQueryAndCheckTiming(); Assert.That(driver.ChosenElements, Has.Member(element)); }
public void When_filling_in_file_field_It_doesnt_click() { var element = new StubElement(); element.StubAttribute("type", "file"); driver.StubField("Some field locator", element); session.FillIn("Some field locator").With("some value for the field"); Assert.That(driver.ClickedElements, Is.Empty); spyRobustWrapper.DeferredActions.Single()(); Assert.That(driver.ClickedElements, Has.No.Member(element)); }
public void When_checking_a_checkbox_It_find_fields_and_checks_robustly() { var element = new StubElement(); driver.StubField("Some checkbox locator", element); session.Check("Some checkbox locator"); Assert.That(driver.CheckedElements, Has.No.Member(element)); spyRobustWrapper.DeferredActions.Single()(); Assert.That(driver.CheckedElements, Has.Member(element)); }
public void It_makes_robust_call_to_find_then_hover_element_on_underlying_driver() { var element = new StubElement(); driver.StubCss("something.to hover", element, browserSession); spyRobustWrapper.AlwaysReturnFromRobustly(element); browserSession.FindCss("something.to hover").Hover(); RunQueryAndCheckTiming(); Assert.That(driver.FindCssRequests, Is.Empty, "Finder call not deferred"); Assert.That(driver.HoveredElements, Has.Member(element)); }
public void When_unchecking_a_checkbox_It_finds_field_and_unchecks_robustly() { var element = new StubElement(); driver.StubField("Some checkbox locator", element, browserSession); browserSession.Uncheck("Some checkbox locator"); Assert.That(driver.UncheckedElements, Has.No.Member(element)); RunQueryAndCheckTiming(); Assert.That(driver.UncheckedElements, Has.Member(element)); }
public void When_filling_in_a_field_with_force_all_events_It_clicks_to_ensure_focus() { var element = new StubElement(); driver.StubField("Some field locator", element, browserSession); browserSession.FillIn("Some field locator").With("some value for the field", true); Assert.That(driver.ClickedElements, Is.Empty); RunQueryAndCheckTiming(); Assert.That(driver.ClickedElements, Has.Member(element)); }
public void When_choosing_a_radio_button_It_finds_field_and_chooses_robustly() { var element = new StubElement(); driver.StubField("Some radio locator", element); session.Choose("Some radio locator"); Assert.That(driver.ChosenElements, Has.No.Member(element)); spyRobustWrapper.DeferredActions.Single()(); Assert.That(driver.ChosenElements, Has.Member(element)); }