├── .gitignore
├── History.md
├── LICENSE.txt
├── README.md
├── images
└── coypu.jpg
└── src
├── Coypu.AcceptanceTests
├── BasicAuth.cs
├── Coypu.AcceptanceTests.csproj
├── Examples
│ ├── ApiExamples.cs
│ ├── CheckboxExamples.cs
│ ├── ClickExamples.cs
│ ├── CustomSeleniumBrowserSession.cs
│ ├── EnterTextExamples.cs
│ ├── FindExamples.cs
│ ├── HasExamples.cs
│ ├── ModalDialogExamples.cs
│ ├── SelectFromExamples.cs
│ ├── ShowsExamples.cs
│ ├── WindowExamples.cs
│ └── WithinExamples.cs
├── FindAllWithPredicateAndRetries.cs
├── InnerAndOuterHtml.cs
├── Location.cs
├── MultipleSessions.cs
├── PathHelper.cs
├── Properties
│ ├── AssemblyInfo.cs
│ └── ParallelizableAssemblyInfo.cs
├── Screenshots.cs
├── SnapshotElementScope.cs
├── StaleScopeExamples.cs
├── States.cs
├── TextPrecisionAndMatch.cs
├── WaitAndRetryExamples.cs
├── WebRequests.cs
├── html
│ ├── states.htm
│ ├── test-card.png
│ └── tricky.htm
└── sites
│ └── SelfHostedSite.cs
├── Coypu.Drivers.Tests
├── Coypu.Drivers.Tests.csproj
├── DriverSpecs.cs
├── When_accessing_attributes.cs
├── When_checking.cs
├── When_choosing.cs
├── When_clicking.cs
├── When_executing_script.cs
├── When_finding_all_elements_by_css.cs
├── When_finding_all_elements_by_xpath.cs
├── When_finding_an_element_by_css.cs
├── When_finding_an_element_by_xpath.cs
├── When_finding_buttons.cs
├── When_finding_buttons_within_scope.cs
├── When_finding_fields_by_container_label.cs
├── When_finding_fields_by_for_attribute.cs
├── When_finding_fields_by_name.cs
├── When_finding_fields_by_placeholder.cs
├── When_finding_fields_by_value.cs
├── When_finding_fields_id.cs
├── When_finding_fields_within_scope.cs
├── When_finding_fieldsets.cs
├── When_finding_frames.cs
├── When_finding_ids.cs
├── When_finding_iframes.cs
├── When_finding_links.cs
├── When_finding_sections.cs
├── When_finding_sections_as_divs.cs
├── When_finding_windows.cs
├── When_forced_to_consider_invisible_elements.cs
├── When_getting_cookies.cs
├── When_hovering.cs
├── When_inspecting_dialog_text.cs
├── When_inspecting_html.cs
├── When_inspecting_location.cs
├── When_inspecting_title.cs
├── When_navigating.cs
├── When_refreshing_windows.cs
├── When_saving_screenshots.cs
├── When_selecting_options.cs
├── When_sending_keys_to_elements.cs
├── When_setting_fields.cs
├── When_sizing_windows.cs
├── When_uploading_files.cs
├── When_using_iframes_as_scope.cs
└── html
│ ├── InteractionTestsPage.htm
│ ├── frame1.htm
│ ├── frame2.htm
│ ├── frameset.htm
│ ├── iFrame1.htm
│ ├── iFrame2.htm
│ ├── popUp.htm
│ ├── popUp2.htm
│ ├── table.htm
│ ├── test-card.jpg
│ └── test-card.png
├── Coypu.NUnit
├── Coypu.NUnit.csproj
└── Matchers
│ ├── AggregateMatcher.cs
│ ├── HasAllCssInOrderMatcher.cs
│ ├── HasContentMatcher.cs
│ ├── HasCssMatcher.cs
│ ├── HasNoContentMatcher.cs
│ ├── HasNoCssMatcher.cs
│ ├── HasNoValueMatcher.cs
│ ├── HasValueMatcher.cs
│ └── Shows.cs
├── Coypu.Tests
├── Coypu.Tests.csproj
├── ProxyTests.cs
├── TestBuilders
│ ├── FindsFirstWitNoDisambiguationStrategy.cs
│ └── TestSessionBuilder.cs
├── TestDoubles
│ ├── FakeDriver.cs
│ ├── ImmediateSingleExecutionFakeTimingStrategy.cs
│ ├── SpyRestrictedResourceDownloader.cs
│ ├── SpyTimingStrategy.cs
│ ├── StubDriver.cs
│ ├── StubElement.cs
│ ├── StubWebResources.cs
│ └── StubWebResponse.cs
├── TestException.cs
├── When_applying_match_strategy
│ ├── Any_match_strategy.cs
│ ├── StubElementFinder.cs
│ ├── When_using_first_exact.cs
│ ├── When_using_first_prefer_exact.cs
│ ├── When_using_first_substring.cs
│ ├── When_using_single_exact.cs
│ ├── When_using_single_prefer_exact.cs
│ └── When_using_single_substring.cs
├── When_configuring_options.cs
├── When_interacting_with_the_browser
│ ├── BrowserInteractionTests.cs
│ ├── WhenFindingSingleElements.cs
│ ├── When_building_urls.cs
│ ├── When_clicking_buttons.cs
│ ├── When_clicking_links.cs
│ ├── When_completing_forms.cs
│ ├── When_constructing_xpath.cs
│ ├── When_controlling_the_window.cs
│ ├── When_executing_script.cs
│ ├── When_finding_all_matching_elements.cs
│ ├── When_finding_state.cs
│ ├── When_finding_then_checking_an_element.cs
│ ├── When_finding_then_clicking_an_element.cs
│ ├── When_finding_then_filling_in_any_field.cs
│ ├── When_finding_then_hovering.cs
│ ├── When_finding_then_unchecking_any_element.cs
│ ├── When_insepcting_elements.cs
│ ├── When_inspecting.cs
│ ├── When_inspecting_location.cs
│ ├── When_inspecting_modal_dialogs.cs
│ ├── When_inspecting_the_page.cs
│ ├── When_inspecting_title.cs
│ ├── When_interacting_with_modal_dialogs.cs
│ ├── When_querying_with_any_finder.cs
│ ├── When_saving_screenshots.cs
│ ├── When_scoping_interactions.cs
│ └── When_visiting.cs
├── When_making_browser_interactions_robust
│ ├── TestActions.cs
│ ├── TestQueries.cs
│ ├── When_I_want_to_manage_timing_manually.cs
│ ├── When_querying_for_an_expected_result.cs
│ ├── When_retrying_until_a_timeout.cs
│ ├── When_trying_an_action_until_a_given_state_is_reached.cs
│ └── When_waiting.cs
├── When_making_direct_web_requests
│ └── When_saving_a_resource_from_the_web.cs
├── When_starting_and_ending_sessions.cs
└── proxysettings.json
├── Coypu.sln
├── Coypu
├── Actions
│ ├── AcceptModalDialog.cs
│ ├── BrowserAction.cs
│ ├── CancelModalDialog.cs
│ ├── CheckAction.cs
│ ├── Choose.cs
│ ├── ClickAction.cs
│ ├── DblClickAction.cs
│ ├── DriverAction.cs
│ ├── FillIn.cs
│ ├── Hover.cs
│ ├── LambdaDriverAction.cs
│ ├── Select.cs
│ ├── SendKeys.cs
│ ├── Uncheck.cs
│ └── WaitThenClick.cs
├── ActivatorDriverFactory.cs
├── AmbiguousException.cs
├── AsyncExtensions.cs
├── BrowserSession.cs
├── BrowserWindow.cs
├── Cookies.cs
├── Coypu.csproj
├── DriverFactory.cs
├── DriverProxy.cs
├── DriverProxyType.cs
├── DriverScope.cs
├── Drivers
│ ├── Browser.cs
│ ├── BrowserNotSupportedException.cs
│ ├── Html.cs
│ ├── NoSuchBrowserException.cs
│ ├── Playwright
│ │ ├── Cookies.cs
│ │ ├── Dialogs.cs
│ │ ├── FrameFinder.cs
│ │ ├── PlaywrightDriver.cs
│ │ ├── PlaywrightElement.cs
│ │ ├── PlaywrightFrame.cs
│ │ └── PlaywrightWindow.cs
│ ├── Selenium
│ │ ├── Cookies.cs
│ │ ├── Dialogs.cs
│ │ ├── DriverFactory.cs
│ │ ├── ElementFinder.cs
│ │ ├── FrameFinder.cs
│ │ ├── ImageFormatParser.cs
│ │ ├── MouseControl.cs
│ │ ├── SeleniumElement.cs
│ │ ├── SeleniumExtensions.cs
│ │ ├── SeleniumFrame.cs
│ │ ├── SeleniumWebDriver.cs
│ │ ├── SeleniumWindow.cs
│ │ ├── SeleniumWindowManager.cs
│ │ ├── TextMatcher.cs
│ │ └── WindowHandleFinder.cs
│ └── XPath.cs
├── Element.cs
├── ElementFoundExtensions.cs
├── ElementScope.cs
├── FillInWith.cs
├── FinderException.cs
├── Finders
│ ├── ButtonFinder.cs
│ ├── CssFinder.cs
│ ├── DisambiguationStrategy.cs
│ ├── DocumentElementFinder.cs
│ ├── ElementFinder.cs
│ ├── FieldFinder.cs
│ ├── FieldsetFinder.cs
│ ├── FinderOptionsDisambiguationStrategy.cs
│ ├── FrameFinder.cs
│ ├── IdFinder.cs
│ ├── LinkFinder.cs
│ ├── OptionFinder.cs
│ ├── SectionFinder.cs
│ ├── SelectFinder.cs
│ ├── StateFinder.cs
│ ├── WindowFinder.cs
│ ├── WithTextFinder.cs
│ ├── XPathFinder.cs
│ └── XPathQueryFinder.cs
├── FullyQualifiedUrlBuilder.cs
├── IDriver.cs
├── Match.cs
├── MissingDialogException.cs
├── MissingHtmlException.cs
├── MissingWindowException.cs
├── Options.cs
├── Properties
│ └── AssemblyInfo.cs
├── Queries
│ ├── ActionSatisfiesPredicateQuery.cs
│ ├── DialogQuery.cs
│ ├── DriverScopeQuery.cs
│ ├── ElementExistsQuery.cs
│ ├── ElementMissingQuery.cs
│ ├── ElementQuery.cs
│ ├── ElementScopeQuery.cs
│ ├── FindAllCssWithPredicateQuery.cs
│ ├── FindAllXPathWithPredicateQuery.cs
│ ├── HasContentMatchQuery.cs
│ ├── HasContentQuery.cs
│ ├── HasDialogQuery.cs
│ ├── HasNoContentMatchQuery.cs
│ ├── HasNoContentQuery.cs
│ ├── HasNoValueQuery.cs
│ ├── HasValueQuery.cs
│ ├── LambdaPredicateQuery.cs
│ ├── LambdaQuery.cs
│ ├── PredicateQuery.cs
│ ├── Query.cs
│ ├── WindowExistsQuery.cs
│ └── WindowMissingQuery.cs
├── Scope.cs
├── SelectFrom.cs
├── SessionConfiguration.cs
├── SnapshotElementScope.cs
├── StaleElementException.cs
├── State.cs
├── SynchronisedElementScope.cs
├── Timing
│ ├── RetryUntilTimeoutTimingStrategy.cs
│ ├── StopwatchWaiter.cs
│ ├── TimingStrategy.cs
│ └── Waiter.cs
├── UrlBuilder.cs
└── WebRequests
│ ├── RequestCookieInjector.cs
│ ├── RestrictedResourceDownloader.cs
│ ├── WebClientWithCookies.cs
│ └── WebRequestCookieInjector.cs
├── IMPORTANT.txt
└── NuGet.config
/.gitignore:
--------------------------------------------------------------------------------
1 | obj
2 | bin
3 | deploy
4 | deploy/*
5 | temp/
6 | _ReSharper.*
7 | <<<<<<< HEAD
8 | *.ReSharper.user
9 | *.csproj.user
10 | *.sln.*.user
11 | *.resharper.user
12 | =======
13 | *.user
14 | >>>>>>> citizenmatt-watin
15 | *.resharper
16 | *.suo
17 | *.cache
18 | ~$*.DS_Store
19 | .DS_Store
20 | ._*
21 | examples/self_test
22 | TestResult.xml
23 | .idea
24 | *.swp
25 | Coypu*.zip
26 | Coypu*.nupkg
27 | chromedriver.log
28 | Coypu-*.wrap
29 | src/packages
30 | /src/.vs/*
31 | /src/.vs/Coypu/v15/Server/sqlite3/*
32 | /src/.vs/Coypu/v15/Server/sqlite3*
33 | /src/.vs/Coypu/v15/Server/*
34 | *.ide
35 | /.vs/slnx.sqlite
36 | /src/Coypu.Tests/Coypu.Tests.nuget.props
37 | /src/Coypu.NUnit/Coypu.NUnit.nuget.props
38 | /src/Coypu.Drivers.Tests/Coypu.Drivers.Tests.nuget.targets
39 | /src/Coypu.Drivers.Tests/Coypu.Drivers.Tests.nuget.props
40 | /src/Coypu.AcceptanceTests/Coypu.AcceptanceTests.nuget.targets
41 | /src/Coypu.AcceptanceTests/Coypu.AcceptanceTests.nuget.props
42 | /src/Coypu.AcceptanceTests/project.lock.json
43 | /src/Coypu/project.lock.json
44 |
--------------------------------------------------------------------------------
/LICENSE.txt:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2018 Adrian Longley & Contributors
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/images/coypu.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/featurist/coypu/889ebb8d91b03d8fa7bd348cc0788d30d1c6b6c2/images/coypu.jpg
--------------------------------------------------------------------------------
/src/Coypu.AcceptanceTests/BasicAuth.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.IO;
3 | using System.Text;
4 | using System.Threading;
5 | using Coypu.AcceptanceTests.Sites;
6 | using Coypu.Drivers.Playwright;
7 | using Coypu.NUnit.Matchers;
8 | using NUnit.Framework;
9 |
10 | namespace Coypu.AcceptanceTests
11 | {
12 | [TestFixture]
13 | public class BasicAuth
14 | {
15 | private SelfHostedSite site;
16 | private BrowserSession browser;
17 |
18 | [SetUp]
19 | public void SetUp()
20 | {
21 | site = new SelfHostedSite();
22 | }
23 |
24 | [TearDown]
25 | public void TearDown()
26 | {
27 | browser.Dispose();
28 | site.Dispose();
29 | }
30 |
31 | [Test]
32 | public void It_passes_through_basic_auth_from_url_as_auth_header()
33 | {
34 | var configuration = new SessionConfiguration
35 | {
36 | Timeout = TimeSpan.FromMilliseconds(1000),
37 | Port = site.BaseUri.Port,
38 | AppHost = "http://someUser:passw0rd@localhost",
39 | Driver = typeof(PlaywrightDriver), // Selenium can't do this
40 | Headless = false,
41 | Browser = Drivers.Browser.Chromium
42 | };
43 |
44 | browser = new BrowserSession(configuration);
45 | browser.Visit("/");
46 |
47 | browser.Visit("/headers");
48 | Assert.That(browser, Shows.Content("Authorization: " + GetBasicAuthHeader("someUser", "passw0rd")));
49 | }
50 |
51 | private string GetBasicAuthHeader(string username, string password)
52 | {
53 | var auth = $"{username}:{password}";
54 | var bytes = Encoding.UTF8.GetBytes(auth);
55 | return "Basic " + Convert.ToBase64String(bytes);
56 | }
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/src/Coypu.AcceptanceTests/Coypu.AcceptanceTests.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 | {6E5D29AC-14C4-4BBE-826D-F8EEA1B40900}
4 | net6.0
5 | true
6 | false
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 | html\%(Filename)%(Extension)
30 | PreserveNewest
31 |
32 |
33 | Always
34 |
35 |
36 |
37 |
--------------------------------------------------------------------------------
/src/Coypu.AcceptanceTests/Examples/CheckboxExamples.cs:
--------------------------------------------------------------------------------
1 | using NUnit.Framework;
2 |
3 | namespace Coypu.AcceptanceTests.Examples
4 | {
5 | public class CheckboxExamples : WaitAndRetryExamples
6 | {
7 | [Test]
8 | public void Can_find_checkbox_and_check_it()
9 | {
10 | var checkbox = Browser.FindCss("#uncheckedBox");
11 | checkbox.Check();
12 | Assert.IsTrue(Browser.FindField("uncheckedBox")
13 | .Selected);
14 | }
15 |
16 | [Test]
17 | public void Can_find_checkbox_and_uncheck_it()
18 | {
19 | var checkbox = Browser.FindCss("#checkedBox");
20 | checkbox.Uncheck();
21 | Assert.IsFalse(Browser.Query(() => Browser.FindField("checkedBox")
22 | .Selected,
23 | false));
24 | }
25 |
26 | [Test]
27 | public void Check_example()
28 | {
29 | Browser.Check("uncheckedBox");
30 | Assert.IsTrue(Browser.FindField("uncheckedBox")
31 | .Selected);
32 | }
33 |
34 | [Test]
35 | public void Uncheck_example()
36 | {
37 | Browser.Uncheck("checkedBox");
38 | Assert.IsFalse(Browser.Query(() => Browser.FindField("checkedBox")
39 | .Selected,
40 | false));
41 | }
42 | }
43 | }
--------------------------------------------------------------------------------
/src/Coypu.AcceptanceTests/Examples/EnterTextExamples.cs:
--------------------------------------------------------------------------------
1 | using System.IO;
2 | using NUnit.Framework;
3 |
4 | namespace Coypu.AcceptanceTests.Examples
5 | {
6 | public class EnterTextExamples : WaitAndRetryExamples
7 | {
8 | [Test]
9 | public void FillIn_file_example()
10 | {
11 | const string someLocalFile = @"local.file";
12 | try
13 | {
14 | var directoryInfo = new DirectoryInfo(Path.GetTempPath());
15 | var fullPath = Path.Combine(directoryInfo.FullName, someLocalFile);
16 | using (File.Create(fullPath)) { }
17 |
18 | Browser.FillIn("forLabeledFileFieldId")
19 | .With(fullPath);
20 | var findAgain = Browser.FindField("forLabeledFileFieldId");
21 | Assert.That(findAgain.Value, Does.EndWith(someLocalFile));
22 | }
23 | finally
24 | {
25 | File.Delete(someLocalFile);
26 | }
27 | }
28 |
29 | [Test]
30 | public void FillInWith_element_example()
31 | {
32 | Browser.FindField("scope2ContainerLabeledTextInputFieldId")
33 | .FillInWith("New text input value");
34 | Assert.That(Browser.FindField("scope2ContainerLabeledTextInputFieldId")
35 | .Value,
36 | Is.EqualTo("New text input value"));
37 | }
38 |
39 | [Test]
40 | public void FillInWith_example()
41 | {
42 | Browser.FillIn("scope2ContainerLabeledTextInputFieldId")
43 | .With("New text input value");
44 | Assert.That(Browser.FindField("scope2ContainerLabeledTextInputFieldId")
45 | .Value,
46 | Is.EqualTo("New text input value"));
47 | }
48 |
49 | [Test]
50 | public void SendKeys_example()
51 | {
52 | Browser.FindField("containerLabeledTextInputFieldId")
53 | .SendKeys(" - send these keys");
54 | Assert.That(Browser.FindField("containerLabeledTextInputFieldId")
55 | .Value,
56 | Is.EqualTo("text input field two val - send these keys"));
57 | }
58 | }
59 | }
--------------------------------------------------------------------------------
/src/Coypu.AcceptanceTests/Examples/ModalDialogExamples.cs:
--------------------------------------------------------------------------------
1 | using NUnit.Framework;
2 |
3 | namespace Coypu.AcceptanceTests.Examples
4 | {
5 | public class ModalDialogExamples : WaitAndRetryExamples
6 | {
7 | [Test]
8 | public void AcceptModalDialog_example()
9 | {
10 | Browser.AcceptAlert("You have triggered an alert and this is the text.", () => {
11 | Browser.ClickLink("Trigger an alert");
12 | });
13 | Browser.FindLink("Trigger an alert - accepted")
14 | .Now();
15 | }
16 |
17 | [Test]
18 | public void CancelModalDialog_example()
19 | {
20 | Browser.CancelConfirm(() => {
21 | Browser.ClickLink("Trigger a confirm");
22 | });
23 | Browser.FindLink("Trigger a confirm - cancelled")
24 | .Now();
25 | }
26 |
27 | [Test]
28 | public void ModalDialog_while_multiple_windows_are_open()
29 | {
30 | Browser.ClickLink("Open pop up window");
31 | Browser.CancelConfirm(() => {
32 | Browser.ClickLink("Trigger a confirm");
33 | });
34 | Browser.FindLink("Trigger a confirm - cancelled")
35 | .Now();
36 | }
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/src/Coypu.AcceptanceTests/InnerAndOuterHtml.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Text.RegularExpressions;
3 | using NUnit.Framework;
4 |
5 | namespace Coypu.AcceptanceTests
6 | {
7 | [TestFixture]
8 | public class InnerAndOuterHtml
9 | {
10 | private SessionConfiguration SessionConfiguration;
11 | private BrowserSession browser;
12 |
13 | [OneTimeSetUp]
14 | public void SetUpFixture()
15 | {
16 | SessionConfiguration = new SessionConfiguration();
17 | SessionConfiguration.Timeout = TimeSpan.FromMilliseconds(1000);
18 | browser = new BrowserSession(SessionConfiguration);
19 |
20 | browser.Visit(PathHelper.GetPageHtmlPath("table.htm"));
21 | }
22 |
23 | [OneTimeTearDown]
24 | public void TearDownFixture()
25 | {
26 | browser.Dispose();
27 | }
28 |
29 | [Test]
30 | public void GrabsTheOuterHTMLFromAnElement()
31 | {
32 | var outerHTML = Normalise(browser.FindCss("table").OuterHTML);
33 | Assert.That(outerHTML, Is.EqualTo("
"));
34 | }
35 |
36 | [Test]
37 | public void GrabsTheInnerHTMLFromAnElement()
38 | {
39 | var innerHTML = Normalise(browser.FindCss("table").InnerHTML);
40 | Assert.That(innerHTML, Is.EqualTo("name | age |
---|
bob | 12 |
jane | 79 |
"));
41 | }
42 |
43 | private static string Normalise(string innerHtml)
44 | {
45 | return new Regex(@"\s+", RegexOptions.Multiline).Replace(innerHtml, "").ToLower();
46 | }
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/src/Coypu.AcceptanceTests/MultipleSessions.cs:
--------------------------------------------------------------------------------
1 | using System.IO;
2 | using NUnit.Framework;
3 |
4 | namespace Coypu.AcceptanceTests
5 | {
6 | [TestFixture]
7 | public class MultipleSessions
8 | {
9 | [Test]
10 | public void Two_browser_sessions_can_be_controlled_independently()
11 | {
12 | using (var sessionOne = new BrowserSession())
13 | {
14 | using (var sessionTwo = new BrowserSession())
15 | {
16 |
17 | VisitTestPage(sessionOne);
18 | VisitTestPage(sessionTwo);
19 |
20 | sessionOne.FindCss("input[type=text]", new Options { Match = Match.First }).FillInWith("from session one");
21 | sessionTwo.FindCss("input[type=text]", new Options { Match = Match.First }).FillInWith("from session two");
22 |
23 | Assert.That(sessionOne.FindCss("input[type=text]", new Options { Match = Match.First }).Value, Is.EqualTo("from session one"));
24 | Assert.That(sessionTwo.FindCss("input[type=text]", new Options { Match = Match.First }).Value, Is.EqualTo("from session two"));
25 | }
26 | }
27 | }
28 |
29 | private void VisitTestPage(BrowserSession browserSession)
30 | {
31 | browserSession.Visit(PathHelper.GetPageHtmlPath("InteractionTestsPage.htm"));
32 | }
33 | }
34 | }
--------------------------------------------------------------------------------
/src/Coypu.AcceptanceTests/PathHelper.cs:
--------------------------------------------------------------------------------
1 | using System.IO;
2 | using NUnit.Framework;
3 |
4 | namespace Coypu.AcceptanceTests;
5 |
6 | public static class PathHelper
7 | {
8 | public static string GetPageHtmlPath(string page)
9 | {
10 | var schema = "file:///";
11 | if (TestContext.CurrentContext.TestDirectory.Length > 0 &&
12 | TestContext.CurrentContext.TestDirectory[0] == '/')
13 | {
14 | schema = "file://";
15 | }
16 | return schema + Path.Combine(TestContext.CurrentContext.TestDirectory, "html", page).Replace("\\", "/");
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/src/Coypu.AcceptanceTests/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.InteropServices;
3 |
4 | // General Information about an assembly is controlled through the following
5 | // set of attributes. Change these attribute values to modify the information
6 | // associated with an assembly.
7 |
8 | [assembly: AssemblyTitle("Coypu.AcceptanceTests")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("Coypu.AcceptanceTests")]
13 | [assembly: AssemblyCopyright("Copyright © Adrian Longley and contributors 2011-2018")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 |
21 | [assembly: ComVisible(false)]
22 |
23 | // The following GUID is for the ID of the typelib if this project is exposed to COM
24 |
25 | [assembly: Guid("da05f0fa-4eb8-4204-b397-50e2d4c1252b")]
26 |
27 | // Version information for an assembly consists of the following four values:
28 | //
29 | // Major Version
30 | // Minor Version
31 | // Build Number
32 | // Revision
33 | //
34 | // You can specify all the values or you can default the Build and Revision Numbers
35 | // by using the '*' as shown below:
36 | // [assembly: AssemblyVersion("1.0.*")]
37 |
38 | [assembly: AssemblyVersion("3.14.0.0")]
39 | [assembly: AssemblyFileVersion("3.14.0.0")]
40 |
--------------------------------------------------------------------------------
/src/Coypu.AcceptanceTests/Properties/ParallelizableAssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using NUnit.Framework;
2 |
3 | [assembly: Parallelizable(ParallelScope.Fixtures)]
4 | [assembly: LevelOfParallelism(4)]
--------------------------------------------------------------------------------
/src/Coypu.AcceptanceTests/Screenshots.cs:
--------------------------------------------------------------------------------
1 | using System.IO;
2 | using NUnit.Framework;
3 |
4 | namespace Coypu.AcceptanceTests
5 | {
6 | [TestFixture]
7 | public class Screenshots : WaitAndRetryExamples
8 | {
9 | private static void SaveFileToAssertItExists(BrowserWindow browserWindow, string fileName)
10 | {
11 | try
12 | {
13 | browserWindow.SaveScreenshot(fileName);
14 | Assert.That(File.Exists(fileName), "Expected screenshot saved to " + new FileInfo(fileName).FullName);
15 | }
16 | finally
17 | {
18 | if (File.Exists(fileName))
19 | File.Delete(fileName);
20 | }
21 | }
22 |
23 | [Test]
24 | public void CapturesCorrectWindow()
25 | {
26 | Browser.ClickLink("Open pop up window");
27 | var popUp = Browser.FindWindow("Pop Up Window");
28 | popUp.Visit(PathHelper.GetPageHtmlPath("test-card.jpg"));
29 | popUp.ResizeTo(800, 600);
30 | Browser.FindCss("body").Click();
31 |
32 | SaveFileToAssertItExists(popUp, "screenshot-test-card.jpg");
33 | }
34 |
35 | [Test]
36 | public void SavesJpgToSpecifiedLocation()
37 | {
38 | Browser.Visit(PathHelper.GetPageHtmlPath("test-card.jpg"));
39 | Browser.ResizeTo(800, 600);
40 |
41 | SaveFileToAssertItExists(Browser, "screenshot-test-card.jpg");
42 | }
43 |
44 | [Test]
45 | public void SavesPngToSpecifiedLocation()
46 | {
47 | Browser.Visit(PathHelper.GetPageHtmlPath("test-card.png"));
48 | Browser.ResizeTo(800, 600);
49 |
50 | SaveFileToAssertItExists(Browser,"screenshot-test-card.png");
51 | }
52 | }
53 | }
--------------------------------------------------------------------------------
/src/Coypu.AcceptanceTests/WaitAndRetryExamples.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.IO;
3 | using Coypu.Drivers.Playwright;
4 | using Coypu.Drivers.Selenium;
5 | using NUnit.Framework;
6 | using NUnit.Framework.Interfaces;
7 |
8 | namespace Coypu.AcceptanceTests
9 | {
10 | public class WaitAndRetryExamples
11 | {
12 | protected BrowserSession Browser;
13 |
14 | [OneTimeSetUp]
15 | public void SetUpFixture()
16 | {
17 | var configuration = new SessionConfiguration
18 | {
19 | Browser = Drivers.Browser.Chrome,
20 | Driver = typeof(PlaywrightDriver),
21 | Headless = true
22 | };
23 | Browser = new BrowserSession(configuration);
24 | }
25 |
26 | [OneTimeTearDown]
27 | public void TearDown()
28 | {
29 | Browser.Dispose();
30 | }
31 |
32 | [SetUp]
33 | public void SetUp()
34 | {
35 | ReloadTestPageWithDelay();
36 | }
37 |
38 | [TearDown]
39 | public void TearDownOnFail()
40 | {
41 | if (TestContext.CurrentContext.Result.Outcome.Status != TestStatus.Failed) return;
42 | TearDown();
43 | SetUpFixture();
44 | }
45 |
46 | protected void ApplyAsyncDelay()
47 | {
48 | // Hide the HTML then bring back after a short delay to test robustness
49 | Browser.ExecuteScript("window.holdIt = window.document.body.innerHTML;");
50 | Browser.ExecuteScript("window.document.body.innerHTML = '';");
51 | Browser.ExecuteScript("setTimeout(function() {document.body.innerHTML = window.holdIt},250)");
52 | }
53 |
54 | protected void ReloadTestPage()
55 | {
56 | Browser.Visit(PathHelper.GetPageHtmlPath("InteractionTestsPage.htm"));
57 | }
58 |
59 | protected void ReloadTestPageWithDelay()
60 | {
61 | ReloadTestPage();
62 | ApplyAsyncDelay();
63 | }
64 | }
65 | }
66 |
--------------------------------------------------------------------------------
/src/Coypu.AcceptanceTests/html/states.htm:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
9 |
10 |
11 |
12 | State one reached
13 |
14 |
15 | State two reached
16 |
17 |
18 | State three reached
19 |
20 |
21 |
--------------------------------------------------------------------------------
/src/Coypu.AcceptanceTests/html/test-card.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/featurist/coypu/889ebb8d91b03d8fa7bd348cc0788d30d1c6b6c2/src/Coypu.AcceptanceTests/html/test-card.png
--------------------------------------------------------------------------------
/src/Coypu.AcceptanceTests/html/tricky.htm:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Pop Up Window
6 |
7 |
8 |
12 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/src/Coypu.Drivers.Tests/Coypu.Drivers.Tests.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 | {310D5EB9-2B2A-406E-8B8E-FBC85D882F54}
4 | net6.0
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 | PreserveNewest
29 |
30 |
31 |
32 |
--------------------------------------------------------------------------------
/src/Coypu.Drivers.Tests/When_accessing_attributes.cs:
--------------------------------------------------------------------------------
1 | using Shouldly;
2 | using NUnit.Framework;
3 |
4 | namespace Coypu.Drivers.Tests
5 | {
6 | internal class When_accessing_attributes : DriverSpecs
7 | {
8 | [Test]
9 | public void Exposes_element_attributes()
10 | {
11 | var formWithAttributesToTest = Id("attributeTestForm", Root, DefaultOptions);
12 | formWithAttributesToTest["id"].ShouldBe("attributeTestForm");
13 | formWithAttributesToTest["method"].ShouldBe("post");
14 | formWithAttributesToTest["action"].ShouldBe("http://somesite.com/action.htm");
15 | formWithAttributesToTest["target"].ShouldBe("_parent");
16 | }
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/src/Coypu.Drivers.Tests/When_choosing.cs:
--------------------------------------------------------------------------------
1 | using Shouldly;
2 | using NUnit.Framework;
3 |
4 | namespace Coypu.Drivers.Tests
5 | {
6 | internal class When_choosing : DriverSpecs
7 | {
8 | [Test]
9 | public void Chooses_radio_button_from_list()
10 | {
11 | var radioButton1 = Field("chooseRadio1");
12 | radioButton1.Selected.ShouldBeFalse();
13 |
14 | // Choose 1
15 | Driver.Choose(radioButton1);
16 |
17 | var radioButton2 = Field("chooseRadio2");
18 | radioButton2.Selected.ShouldBeFalse();
19 |
20 | // Choose 2
21 | Driver.Choose(radioButton2);
22 |
23 | // New choice is now selected
24 | radioButton2 = Field("chooseRadio2");
25 | radioButton2.Selected.ShouldBeTrue();
26 |
27 | // Originally selected is no longer selected
28 | radioButton1 = Field("chooseRadio1");
29 | radioButton1.Selected.ShouldBeFalse();
30 | }
31 |
32 |
33 | [Test]
34 | public void Fires_onclick_event()
35 | {
36 | var radio = Field("chooseRadio2");
37 | radio.Value.ShouldBe("Radio buttons - 2nd value");
38 |
39 | Driver.Choose(radio);
40 |
41 | Field("chooseRadio2", Root).Value.ShouldBe("Radio buttons - 2nd value - clicked");
42 | }
43 | }
44 | }
--------------------------------------------------------------------------------
/src/Coypu.Drivers.Tests/When_clicking.cs:
--------------------------------------------------------------------------------
1 | using System.Linq;
2 | using Coypu.Finders;
3 | using Shouldly;
4 | using NUnit.Framework;
5 |
6 | namespace Coypu.Drivers.Tests
7 | {
8 | public class When_clicking : DriverSpecs
9 | {
10 | [Test]
11 | public void Clicks_the_underlying_element()
12 | {
13 | var element = Button("clickMeTest");
14 | element.Value.ShouldBe("Click me");
15 |
16 | Driver.Click(element);
17 |
18 | Button("clickMeTest").Value.ShouldBe("Click me - clicked");
19 | }
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/src/Coypu.Drivers.Tests/When_executing_script.cs:
--------------------------------------------------------------------------------
1 | using Coypu.Finders;
2 | using Shouldly;
3 | using NUnit.Framework;
4 | using System;
5 | using Coypu.Tests;
6 |
7 | namespace Coypu.Drivers.Tests
8 | {
9 | internal class When_executing_script : DriverSpecs
10 | {
11 | [Test]
12 | public void Runs_the_script_in_the_browser()
13 | {
14 | Button("firstButtonId").Text.ShouldBe("first button");
15 |
16 | Driver.ExecuteScript("document.getElementById('firstButtonId').innerHTML = 'script executed';", Root);
17 |
18 | Button("firstButtonId").Text.ShouldBe("script executed");
19 | }
20 |
21 | [Test]
22 | public void Passes_the_arguments_to_the_browser()
23 | {
24 | Button("firstButtonId").Text.ShouldBe("first button");
25 |
26 | Driver.ExecuteScript("arguments[0].innerHTML = 'script executed ' + arguments[1];", Root, Button("firstButtonId"), 5);
27 |
28 | Button("firstButtonId").Text.ShouldBe("script executed 5");
29 | }
30 |
31 | [Test]
32 | public void Returns_the_result()
33 | {
34 | Driver.ExecuteScript("return document.getElementById('firstButtonId').innerHTML;", Root).ShouldBe("first button");
35 | Driver.ExecuteScript("return 1234;", Root).ShouldBe(1234);
36 | }
37 |
38 | [Test]
39 | public void Returns_the_result_typed()
40 | {
41 | string str = Driver.ExecuteScript("return 'miles';", Root);
42 | str.GetType().ShouldBe(typeof(string));
43 |
44 | int integer = Driver.ExecuteScript("return 1234;", Root);
45 | integer.GetType().ShouldBe(typeof(int));
46 |
47 | DateTime dateTime = Driver.ExecuteScript("return new Date();", Root);
48 | dateTime.GetType().ShouldBe(typeof(DateTime));
49 |
50 | try {
51 | Driver.ExecuteScript("return 'bob';", Root);
52 | throw new TestException("Expected an exception");
53 | } catch(Exception e) {
54 | if (e is TestException) throw;
55 | };
56 | }
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/src/Coypu.Drivers.Tests/When_finding_all_elements_by_css.cs:
--------------------------------------------------------------------------------
1 | using System.Linq;
2 | using Shouldly;
3 | using NUnit.Framework;
4 |
5 | namespace Coypu.Drivers.Tests
6 | {
7 | internal class When_finding_all_elements_by_css : DriverSpecs
8 | {
9 |
10 | [Test]
11 | public void Returns_empty_if_no_matches()
12 | {
13 | const string shouldNotFind = "#inspectingContent p.css-missing-test";
14 | Assert.That(Driver.FindAllCss(shouldNotFind, Root, DefaultOptions), Is.Empty);
15 | }
16 |
17 | [Test]
18 | public void Returns_all_matches_by_css()
19 | {
20 | const string shouldFind = "#inspectingContent ul#cssTest li";
21 | var all = Driver.FindAllCss(shouldFind, Root, DefaultOptions);
22 | all.Count().ShouldBe(3);
23 | all.ElementAt(1).Text.ShouldBe("two");
24 | all.ElementAt(2).Text.ShouldBe("Me! Pick me!");
25 | }
26 | }
27 | }
--------------------------------------------------------------------------------
/src/Coypu.Drivers.Tests/When_finding_all_elements_by_xpath.cs:
--------------------------------------------------------------------------------
1 | using System.Linq;
2 | using Coypu.Finders;
3 | using Shouldly;
4 | using NUnit.Framework;
5 |
6 | namespace Coypu.Drivers.Tests
7 | {
8 | internal class When_finding_all_elements_by_xpath : DriverSpecs
9 | {
10 | [Test]
11 | public void Returns_empty_if_no_matches()
12 | {
13 | const string shouldNotFind = "//*[@id = 'inspectingContent']//p[@class='css-missing-test']";
14 | Assert.That(Driver.FindAllXPath(shouldNotFind, Root, DefaultOptions), Is.Empty);
15 | }
16 |
17 | [Test]
18 | public void Returns_all_matches_by_xpath()
19 | {
20 | const string shouldFind = "//*[@id='inspectingContent']//ul[@id='cssTest']/li";
21 | var all = Driver.FindAllXPath(shouldFind, Root, DefaultOptions);
22 | all.Count().ShouldBe(3);
23 | all.ElementAt(1).Text.ShouldBe("two");
24 | all.ElementAt(2).Text.ShouldBe("Me! Pick me!");
25 | }
26 | }
27 | }
--------------------------------------------------------------------------------
/src/Coypu.Drivers.Tests/When_finding_an_element_by_xpath.cs:
--------------------------------------------------------------------------------
1 | using System.Text.RegularExpressions;
2 | using Shouldly;
3 | using NUnit.Framework;
4 |
5 | namespace Coypu.Drivers.Tests
6 | {
7 | internal class When_finding_an_element_by_xpath : DriverSpecs
8 | {
9 | [Test]
10 | public void Finds_present_examples()
11 | {
12 | var shouldFind = "//*[@id = 'inspectingContent']//p[@class='css-test']/span";
13 | XPath(shouldFind).Text.ShouldBe("This");
14 |
15 | shouldFind = "//ul[@id='cssTest']/li[3]";
16 | XPath(shouldFind).Text.ShouldBe("Me! Pick me!");
17 | }
18 |
19 | [Test]
20 | public void Does_not_find_missing_examples()
21 | {
22 | const string shouldNotFind = "//*[@id = 'inspectingContent']//p[@class='css-missing-test']";
23 | Assert.Throws(() => XPath(shouldNotFind),
24 | "Expected not to find something at: " + shouldNotFind);
25 | }
26 |
27 | [Test]
28 | public void Only_finds_visible_elements()
29 | {
30 | const string shouldNotFind = "//*[@id = 'inspectingContent']//p[@class='css-test']/img";
31 | Assert.Throws(() => XPath(shouldNotFind),
32 | "Expected not to find something at: " + shouldNotFind);
33 | }
34 | }
35 | }
--------------------------------------------------------------------------------
/src/Coypu.Drivers.Tests/When_finding_buttons_within_scope.cs:
--------------------------------------------------------------------------------
1 | using Coypu.Finders;
2 | using Shouldly;
3 | using NUnit.Framework;
4 |
5 | namespace Coypu.Drivers.Tests
6 | {
7 | public class When_finding_buttons_within_scope : DriverSpecs
8 | {
9 | private DriverScope scope1;
10 | private DriverScope scope2;
11 |
12 | [SetUp]
13 | public void SetUpScope()
14 | {
15 | scope1 = new BrowserWindow(DefaultSessionConfiguration, new IdFinder(Driver, "scope1", Root, DefaultOptions), Driver,null,null,null,DisambiguationStrategy);
16 | scope2 = new BrowserWindow(DefaultSessionConfiguration, new IdFinder(Driver, "scope2", Root, DefaultOptions), Driver,null,null,null,DisambiguationStrategy);
17 | }
18 |
19 | [Test]
20 | public void Finds_button_by_name()
21 | {
22 | Button("scopedButtonName", scope1).Id.ShouldBe("scope1ButtonId");
23 | Button( "scopedButtonName", scope2).Id.ShouldBe("scope2ButtonId");
24 | }
25 |
26 | [Test]
27 | public void Finds_input_button_by_value()
28 | {
29 | Button( "scoped input button", scope1).Id.ShouldBe("scope1InputButtonId");
30 | Button( "scoped input button", scope2).Id.ShouldBe("scope2InputButtonId");
31 | }
32 |
33 | [Test]
34 | public void Finds_button_by_text()
35 | {
36 | Button( "scoped button", scope1).Id.ShouldBe("scope1ButtonId");
37 | Button( "scoped button", scope2).Id.ShouldBe("scope2ButtonId");
38 | }
39 | }
40 | }
--------------------------------------------------------------------------------
/src/Coypu.Drivers.Tests/When_finding_fields_by_name.cs:
--------------------------------------------------------------------------------
1 | using Coypu.Finders;
2 | using Shouldly;
3 | using NUnit.Framework;
4 |
5 | namespace Coypu.Drivers.Tests
6 | {
7 | internal class When_finding_fields_by_name : DriverSpecs {
8 |
9 | [Test]
10 | public void Finds_text_input()
11 | {
12 | Field("containerLabeledTextInputFieldName").Value.ShouldBe("text input field two val");
13 | }
14 |
15 | [Test]
16 | public void Finds_textarea()
17 | {
18 | Field("containerLabeledTextareaFieldName").Value.ShouldBe("textarea field two val");
19 | }
20 |
21 | [Test]
22 | public void Finds_select()
23 | {
24 | Field("containerLabeledSelectFieldName").Id.ShouldBe("containerLabeledSelectFieldId");
25 | }
26 |
27 | [Test]
28 | public void Finds_checkbox()
29 | {
30 | Field("containerLabeledCheckboxFieldName").Value.ShouldBe("checkbox field two val");
31 | }
32 |
33 | [Test]
34 | public void Does_NOT_find_radio_button()
35 | {
36 | Assert.Throws(() => Button("containerLabeledRadioFieldName"));
37 | }
38 |
39 | [Test]
40 | public void Finds_password_input()
41 | {
42 | Field("containerLabeledPasswordFieldName").Id.ShouldBe("containerLabeledPasswordFieldId");
43 | }
44 |
45 | [Test]
46 | public void Finds_file_input()
47 | {
48 | Field("containerLabeledFileFieldName").Id.ShouldBe("containerLabeledFileFieldId");
49 | }
50 |
51 | }
52 | }
--------------------------------------------------------------------------------
/src/Coypu.Drivers.Tests/When_finding_fields_by_placeholder.cs:
--------------------------------------------------------------------------------
1 | using Shouldly;
2 | using NUnit.Framework;
3 |
4 | namespace Coypu.Drivers.Tests
5 | {
6 | internal class When_finding_fields_by_placeholder : DriverSpecs
7 | {
8 | [Test]
9 | public void Finds_text_field_by_placeholder()
10 | {
11 | Field("text input field with a placeholder").Id.ShouldBe("textInputFieldWithPlaceholder");
12 | Field("textarea field with a placeholder").Id.ShouldBe("textareaFieldWithPlaceholder");
13 | }
14 | }
15 | }
--------------------------------------------------------------------------------
/src/Coypu.Drivers.Tests/When_finding_fields_by_value.cs:
--------------------------------------------------------------------------------
1 | using Shouldly;
2 | using NUnit.Framework;
3 |
4 | namespace Coypu.Drivers.Tests
5 | {
6 | internal class When_finding_fields_by_value : DriverSpecs
7 | {
8 | [Test]
9 | public void Finds_radio_button_by_value() {
10 | Field("radio field one val").Name.ShouldBe("forLabeledRadioFieldName");
11 | Field("radio field two val").Name.ShouldBe("containerLabeledRadioFieldName");
12 | }
13 |
14 | [Test]
15 | public void Finds_checkbox_by_value() {
16 | Field("checkbox one val").Name.ShouldBe("checkboxByValueOneFieldName");
17 | Field("checkbox two val").Name.ShouldBe("checkboxByValueTwoFieldName");
18 | }
19 |
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/src/Coypu.Drivers.Tests/When_finding_fieldsets.cs:
--------------------------------------------------------------------------------
1 | using Shouldly;
2 | using NUnit.Framework;
3 |
4 | namespace Coypu.Drivers.Tests
5 | {
6 | internal class When_finding_fieldsets : DriverSpecs
7 | {
8 | [Test]
9 | public void Finds_by_legend_text()
10 | {
11 | Fieldset("Scope 1").Id.ShouldBe("fieldsetScope1");
12 | Fieldset("Scope 2").Id.ShouldBe("fieldsetScope2");
13 | }
14 |
15 | [Test]
16 | public void Finds_by_id()
17 | {
18 | Fieldset("fieldsetScope1").Id.ShouldBe("fieldsetScope1");
19 | Fieldset("fieldsetScope2").Id.ShouldBe("fieldsetScope2");
20 | }
21 |
22 | [Test]
23 | public void Finds_only_fieldsets()
24 | {
25 | Assert.Throws(() => Fieldset("scope1TextInputFieldId"));
26 | Assert.Throws(() => Fieldset("sectionOne"));
27 | }
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/src/Coypu.Drivers.Tests/When_finding_frames.cs:
--------------------------------------------------------------------------------
1 | using Shouldly;
2 | using NUnit.Framework;
3 |
4 | namespace Coypu.Drivers.Tests
5 | {
6 | internal class When_finding_frames : DriverSpecs
7 | {
8 | protected override string TestPage
9 | {
10 | get { return @"frameset.htm"; }
11 | }
12 |
13 | [Test]
14 | public void Finds_by_header_text()
15 | {
16 | Frame("I am frame one").Name.ShouldBe("frame1");
17 | Frame("I am frame two").Name.ShouldBe("frame2");
18 | }
19 |
20 | [Test]
21 | public void Finds_by_name()
22 | {
23 | Frame("frame1").Name.ShouldBe("frame1");
24 | Frame("frame2").Name.ShouldBe("frame2");
25 | }
26 |
27 | [Test]
28 | public void Finds_by_id()
29 | {
30 | Frame("frame1id").Name.ShouldBe("frame1");
31 | Frame("frame2id").Name.ShouldBe("frame2");
32 | }
33 | }
34 | }
--------------------------------------------------------------------------------
/src/Coypu.Drivers.Tests/When_finding_ids.cs:
--------------------------------------------------------------------------------
1 | using Shouldly;
2 | using NUnit.Framework;
3 |
4 | namespace Coypu.Drivers.Tests
5 | {
6 | public class When_finding_ids : DriverSpecs
7 | {
8 | [Test]
9 | public void Finds_element_by_id()
10 | {
11 | Id("firstLinkId").Id.ShouldBe("firstLinkId");
12 | Id("secondLinkId").Id.ShouldBe("secondLinkId");
13 | }
14 |
15 | [Test]
16 | public void Does_not_find_display_none()
17 | {
18 | Assert.Throws(() => Id("invisibleLinkByDisplayId"));
19 | }
20 |
21 | [Test]
22 | public void Does_not_find_visibility_hidden_links()
23 | {
24 | Assert.Throws(() => Id("invisibleLinkByVisibilityId"));
25 | }
26 |
27 | [Test]
28 | public void Ignores_exact_option()
29 | {
30 | Assert.Throws(() => Id("firstLink", options: Options.Substring));
31 | Assert.Throws(() => Id("firstLink", options: Options.Exact));
32 | }
33 | }
34 | }
--------------------------------------------------------------------------------
/src/Coypu.Drivers.Tests/When_finding_iframes.cs:
--------------------------------------------------------------------------------
1 | using Shouldly;
2 | using NUnit.Framework;
3 |
4 | namespace Coypu.Drivers.Tests
5 | {
6 | internal class When_finding_iframes : DriverSpecs
7 | {
8 | [Test]
9 | public void Finds_by_header_text()
10 | {
11 | Frame("I am iframe one").Id.ShouldBe("iframe1");
12 | Frame("I am iframe two").Id.ShouldBe("iframe2");
13 | }
14 |
15 | [Test]
16 | public void Finds_by_id()
17 | {
18 | Frame("iframe1").Id.ShouldBe("iframe1");
19 | Frame("iframe2").Id.ShouldBe("iframe2");
20 | }
21 |
22 | [Test]
23 | public void Finds_by_title()
24 | {
25 | Frame("iframe one title").Id.ShouldBe("iframe1");
26 | Frame("iframe two title").Id.ShouldBe("iframe2");
27 | }
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/src/Coypu.Drivers.Tests/When_finding_links.cs:
--------------------------------------------------------------------------------
1 | using Shouldly;
2 | using NUnit.Framework;
3 |
4 | namespace Coypu.Drivers.Tests
5 | {
6 | public class When_finding_links : DriverSpecs
7 | {
8 | [Test]
9 | public void Finds_link_by_text()
10 | {
11 | Link("first link").Id.ShouldBe("firstLinkId");
12 | Link("second link").Id.ShouldBe("secondLinkId");
13 | }
14 | [Test]
15 | public void Finds_link_by_href()
16 | {
17 | Link("#link1href").Id.ShouldBe("firstLinkId");
18 | Link("#link2href").Id.ShouldBe("secondLinkId");
19 | }
20 |
21 | [Test]
22 | public void Does_not_find_display_none()
23 | {
24 | Assert.Throws(() => Link("I am an invisible link by display"));
25 | }
26 |
27 | [Test]
28 | public void Does_not_find_visibility_hidden_links()
29 | {
30 | Assert.Throws(() => Link("I am an invisible link by visibility"));
31 | }
32 |
33 | [Test]
34 | public void Finds_a_link_with_both_types_of_quote_in_its_text()
35 | {
36 | Assert.That(Link("I'm a link with \"both\" types of quote in my text").Id, Is.EqualTo("linkWithBothQuotesId"));
37 | }
38 | }
39 | }
--------------------------------------------------------------------------------
/src/Coypu.Drivers.Tests/When_finding_sections.cs:
--------------------------------------------------------------------------------
1 | using Shouldly;
2 | using NUnit.Framework;
3 |
4 | namespace Coypu.Drivers.Tests
5 | {
6 | internal class When_finding_sections : DriverSpecs
7 | {
8 | [Test]
9 | public void Finds_by_h1_text()
10 | {
11 | Section("Section One h1").Id.ShouldBe("sectionOne");
12 | Section("Section Two h1").Id.ShouldBe("sectionTwo");
13 | }
14 |
15 | [Test]
16 | public void Finds_by_h2_text()
17 | {
18 | Section("Section One h2").Id.ShouldBe("sectionOne");
19 | Section("Section Two h2").Id.ShouldBe("sectionTwo");
20 | }
21 |
22 | [Test]
23 | public void Finds_by_h3_text()
24 | {
25 | Section("Section One h3").Id.ShouldBe("sectionOne");
26 | Section("Section Two h3").Id.ShouldBe("sectionTwo");
27 | }
28 |
29 | [Test]
30 | public void Finds_by_h6_text()
31 | {
32 | Section("Section One h6").Id.ShouldBe("sectionOne");
33 | Section("Section Two h6").Id.ShouldBe("sectionTwo");
34 | }
35 |
36 | [Test]
37 | public void Finds_section_by_id()
38 | {
39 | Section("sectionOne").Id.ShouldBe("sectionOne");
40 | Section("sectionTwo").Id.ShouldBe("sectionTwo");
41 | }
42 |
43 |
44 | [Test]
45 | public void Only_finds_div_and_section()
46 | {
47 | Assert.Throws(() => Section("scope1TextInputFieldId"));
48 | Assert.Throws(() => Section("fieldsetScope2"));
49 | }
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/src/Coypu.Drivers.Tests/When_finding_sections_as_divs.cs:
--------------------------------------------------------------------------------
1 | using Shouldly;
2 | using NUnit.Framework;
3 |
4 | namespace Coypu.Drivers.Tests
5 | {
6 | internal class When_finding_sections_as_divs : DriverSpecs
7 | {
8 | [Test]
9 | public void Finds_by_h1_text()
10 | {
11 | Section("Div Section One h1").Id.ShouldBe("divSectionOne");
12 | Section("Div Section Two h1").Id.ShouldBe("divSectionTwo");
13 | }
14 |
15 | [Test]
16 | public void Finds_by_h2_text()
17 | {
18 | Section("Div Section One h2").Id.ShouldBe("divSectionOne");
19 | Section("Div Section Two h2").Id.ShouldBe("divSectionTwo");
20 | }
21 |
22 | [Test]
23 | public void Finds_by_h3_text()
24 | {
25 | Section("Div Section One h3").Id.ShouldBe("divSectionOne");
26 | Section("Div Section Two h3").Id.ShouldBe("divSectionTwo");
27 | }
28 |
29 | [Test]
30 | public void Finds_by_h6_text()
31 | {
32 | Section("Div Section One h6").Id.ShouldBe("divSectionOne");
33 | Section("Div Section Two h6").Id.ShouldBe("divSectionTwo");
34 | }
35 |
36 |
37 | [Test]
38 | public void Finds_by_h2_text_within_child_link()
39 | {
40 | Section("Div Section One h2 with link").Id.ShouldBe("divSectionOneWithLink");
41 | Section("Div Section Two h2 with link").Id.ShouldBe("divSectionTwoWithLink");
42 | }
43 |
44 |
45 | [Test]
46 | public void Finds_by_div_by_id()
47 | {
48 | Section("divSectionOne").Text.ShouldBe(Section("Div Section One h1").Text);
49 | Section("divSectionTwo").Text.ShouldBe(Section("Div Section Two h1").Text);
50 | }
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/src/Coypu.Drivers.Tests/When_forced_to_consider_invisible_elements.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Text.RegularExpressions;
3 | using NUnit.Framework;
4 |
5 | namespace Coypu.Drivers.Tests
6 | {
7 | public class When_forced_to_find_invisible_elements : DriverSpecs
8 | {
9 | [Test]
10 | public void Does_find_hidden_inputs()
11 | {
12 | Assert.That(Field("firstHiddenInputId", options: Options.Invisible)
13 | .Value,
14 | Is.EqualTo("first hidden input"));
15 | Assert.Throws(() => Field("firstHiddenInputId"));
16 | }
17 |
18 | [Test]
19 | public void Does_find_invisible_elements()
20 | {
21 | Assert.That(Button("firstInvisibleInputId", options: Options.Invisible)
22 | .Name,
23 | Is.EqualTo("firstInvisibleInputName"));
24 | Assert.Throws(() => Button("firstInvisibleInputId"));
25 | }
26 |
27 | [Test]
28 | public void Explains_it_cannot_find_invisible_elements_by_text()
29 | {
30 | Assert.Throws(() => Css("#firstInvisibleSpanId", new Regex("I am an invisible span"), options: Options.Invisible));
31 | }
32 | }
33 | }
--------------------------------------------------------------------------------
/src/Coypu.Drivers.Tests/When_hovering.cs:
--------------------------------------------------------------------------------
1 | using Shouldly;
2 | using NUnit.Framework;
3 |
4 | namespace Coypu.Drivers.Tests
5 | {
6 | public class When_hovering : DriverSpecs
7 | {
8 | //Broken in firefox & edge due to the driver not scrolling when moving to an element
9 | [Test]
10 | public void Mouses_over_the_underlying_element()
11 | {
12 | var element = Id("hoverOnMeTest");
13 | element.Text.ShouldBe("Hover on me");
14 | Driver.Hover(element);
15 |
16 | Id("hoverOnMeTest").Text.ShouldBe("Hover on me - hovered");
17 | }
18 | }
19 | }
--------------------------------------------------------------------------------
/src/Coypu.Drivers.Tests/When_inspecting_dialog_text.cs:
--------------------------------------------------------------------------------
1 | using Shouldly;
2 | using NUnit.Framework;
3 | using Coypu.Drivers.Playwright;
4 | namespace Coypu.Drivers.Tests
5 | {
6 | internal class When_inspecting_dialog_text : DriverSpecs
7 | {
8 | [Test]
9 | public void Finds_exact_text_in_alert()
10 | {
11 | if (Driver is PlaywrightDriver)
12 | {
13 | Assert.Ignore("Playwright does not support the obsolete HasDialog API");
14 | }
15 | using (Driver)
16 | {
17 | Driver.Click(Link("Trigger an alert"));
18 | Driver.HasDialog("You have triggered an alert and this is the text.", Root).ShouldBeTrue();
19 | Driver.HasDialog("You have triggered a different alert and this is the different text.", Root).ShouldBeFalse();
20 | }
21 | }
22 | [Test]
23 | public void Finds_exact_text_in_confirm()
24 | {
25 | if (Driver is PlaywrightDriver)
26 | {
27 | Assert.Ignore("Playwright does not support the obsolete HasDialog API");
28 | }
29 | using (Driver)
30 | {
31 | Driver.Click(Link("Trigger a confirm"));
32 | Driver.HasDialog("You have triggered a confirm and this is the text.", Root).ShouldBeTrue();
33 | Driver.HasDialog("You have triggered a different confirm and this is the different text.", Root).ShouldBeFalse();
34 | }
35 | }
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/src/Coypu.Drivers.Tests/When_inspecting_html.cs:
--------------------------------------------------------------------------------
1 | using System.IO;
2 | using System.Text.RegularExpressions;
3 | using NUnit.Framework;
4 | using Coypu.AcceptanceTests;
5 |
6 | namespace Coypu.Drivers.Tests
7 | {
8 | internal class When_inspecting_html : DriverSpecs
9 | {
10 | public void VisitTestPage()
11 | {
12 | Driver.Visit(PathHelper.GetPageHtmlPath("table.htm"), Root);
13 | }
14 |
15 | [Test]
16 | public void FindsElementOuterHTML()
17 | {
18 | VisitTestPage();
19 |
20 | var outerHTML = Normalise(Css("table").OuterHTML);
21 | Assert.That(outerHTML, Is.EqualTo(""));
22 | }
23 |
24 | [Test]
25 | public void FindsElementInnerHTML()
26 | {
27 | VisitTestPage();
28 |
29 | var innerHTML = Normalise(Css("table").InnerHTML);
30 | Assert.That(innerHTML, Is.EqualTo("name | age |
---|
bob | 12 |
jane | 79 |
"));
31 | }
32 |
33 | [Test]
34 | public void FindsWindowOuterHTML()
35 | {
36 | VisitTestPage();
37 |
38 | var outerHTML = Normalise(Driver.Window.OuterHTML);
39 | Assert.That(outerHTML, Is.EqualTo("table"));
40 | }
41 |
42 | [Test]
43 | public void FindsWindowInnerHTML()
44 | {
45 | VisitTestPage();
46 |
47 | var innerHTML = Normalise(Driver.Window.InnerHTML);
48 | Assert.That(innerHTML, Is.EqualTo("table"));
49 | }
50 |
51 | private static string Normalise(string innerHtml)
52 | {
53 | return new Regex(@"\s+<", RegexOptions.Multiline).Replace(innerHtml, "<").Replace(" webdriver=\"true\"","").ToLower().TrimEnd();
54 | }
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/src/Coypu.Drivers.Tests/When_inspecting_location.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Threading;
3 | using Coypu.Actions;
4 | using Coypu.Finders;
5 | using Coypu.Timing;
6 | using NUnit.Framework;
7 |
8 | namespace Coypu.Drivers.Tests
9 | {
10 | internal class When_navigating : DriverSpecs
11 | {
12 | [Test]
13 | public void Gets_the_current_browser_location()
14 | {
15 | Driver.Visit(TestSiteUrl("/"), Root);
16 | Assert.That(Driver.Location(Root), Is.EqualTo(new Uri(TestSiteUrl("/"))));
17 |
18 | Driver.Visit(TestSiteUrl("/auto_login"), Root);
19 | Assert.That(Driver.Location(Root), Is.EqualTo(new Uri(TestSiteUrl("/auto_login"))));
20 | }
21 |
22 | [Test]
23 | public void Gets_location_for_correct_window_scope()
24 | {
25 | Driver.Click(Link("Open pop up window"));
26 | var popUp = new BrowserWindow(DefaultSessionConfiguration, new WindowFinder(Driver, "Pop Up Window", Root, DefaultOptions), Driver, null, null, null, DisambiguationStrategy);
27 | RetryUntilTimeoutTimingStrategy.Retry(() => popUp.Now());
28 | Assert.That(Driver.Location(popUp)
29 | .AbsoluteUri,
30 | Does.EndWith("src/Coypu.Drivers.Tests/bin/Debug/net6.0/html/popup.htm"));
31 | }
32 |
33 | [Test]
34 | public void Not_just_when_set_by_visit()
35 | {
36 | Driver.Visit(TestSiteUrl("/auto_login"), Root);
37 | Driver.ExecuteScript("document.location.href = '" + TestSiteUrl("/resource/bdd") + "'", Root);
38 |
39 | // Seems like WebDriver is not waiting on JS, has exec been made asnyc?
40 | Thread.Sleep(500);
41 |
42 | Assert.That(Driver.Location(Root), Is.EqualTo(new Uri(TestSiteUrl("/resource/bdd"))));
43 | }
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/src/Coypu.Drivers.Tests/When_inspecting_title.cs:
--------------------------------------------------------------------------------
1 | using Shouldly;
2 | using NUnit.Framework;
3 |
4 | namespace Coypu.Drivers.Tests
5 | {
6 | internal class When_inspecting_title : DriverSpecs
7 | {
8 | [Test]
9 | public void Gets_the_current_page_title()
10 | {
11 | Driver.Title(Root).ShouldBe("Coypu interaction tests page");
12 | }
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/src/Coypu.Drivers.Tests/When_navigating.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Coypu.Finders;
3 | using NUnit.Framework;
4 |
5 | namespace Coypu.Drivers.Tests
6 | {
7 | internal class When_inspecting_location : DriverSpecs
8 | {
9 | [Test]
10 | public void Go_back_and_forward_in_history()
11 | {
12 | using (Driver)
13 | {
14 | Driver.Visit(TestSiteUrl("/"), Root);
15 | Driver.Visit(TestSiteUrl("/auto_login"), Root);
16 |
17 | Driver.GoBack(Root);
18 | Assert.That(Driver.Location(Root), Is.EqualTo(new Uri(TestSiteUrl("/"))));
19 |
20 | Driver.GoForward(Root);
21 | Assert.That(Driver.Location(Root), Is.EqualTo(new Uri(TestSiteUrl("/auto_login"))));
22 |
23 | }
24 | }
25 |
26 | [Test]
27 | public void Go_back_and_forward_in_correct_window_scope()
28 | {
29 | using (Driver)
30 | {
31 | Driver.Click(Link("Open pop up window"));
32 | var popUp = new BrowserWindow(DefaultSessionConfiguration, new WindowFinder(Driver, "Pop Up Window", Root, DefaultOptions),
33 | Driver, null, null, null, DisambiguationStrategy);
34 |
35 | Driver.Visit(TestSiteUrl("/auto_login"), Root);
36 | Driver.Visit(TestSiteUrl("/"), popUp);
37 |
38 | Driver.GoBack(popUp);
39 | Assert.That(Driver.Location(popUp).AbsoluteUri,
40 | Does.EndWith("src/Coypu.Drivers.Tests/bin/Debug/net6.0/html/popup.htm"));
41 | Assert.That(Driver.Location(Root).AbsoluteUri, Is.EqualTo(TestSiteUrl("/auto_login")));
42 |
43 | Driver.GoForward(popUp);
44 | Assert.That(Driver.Location(popUp).AbsoluteUri, Is.EqualTo(TestSiteUrl("/")));
45 |
46 | Driver.GoBack(Root);
47 | Assert.That(Driver.Location(Root).AbsoluteUri, Does.EndWith("/html/InteractionTestsPage.htm"));
48 | Assert.That(Driver.Location(popUp).AbsoluteUri, Is.EqualTo(TestSiteUrl("/")));
49 | }
50 | }
51 | }
52 | }
--------------------------------------------------------------------------------
/src/Coypu.Drivers.Tests/When_refreshing_windows.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Coypu.Finders;
3 | using Coypu.Timing;
4 | using NUnit.Framework;
5 |
6 | namespace Coypu.Drivers.Tests
7 | {
8 | internal class When_refreshing_windows : DriverSpecs
9 | {
10 | [Test]
11 | public void RefreshCausesPageToReload()
12 | {
13 | RefreshCausesScopeToReload(Root);
14 | }
15 |
16 | [Test]
17 | public void RefreshesCorrectWindowScope()
18 | {
19 | Driver.Click(Link("Open pop up window"));
20 | var popUp = new BrowserWindow(DefaultSessionConfiguration, new WindowFinder(Driver,"Pop Up Window",Root,DefaultOptions), Driver, null, null, null, DisambiguationStrategy);
21 | RetryUntilTimeoutTimingStrategy.Retry(() => popUp.Now());
22 | RefreshCausesScopeToReload(popUp);
23 | }
24 |
25 | private static void RefreshCausesScopeToReload(DriverScope driverScope)
26 | {
27 | var tickBeforeRefresh = long.Parse(Driver.ExecuteScript("return window.SpecData.CurrentTick;", driverScope).ToString());
28 |
29 | Driver.Refresh(driverScope);
30 |
31 | var tickAfterRefresh = long.Parse(Driver.ExecuteScript("return window.SpecData.CurrentTick;", driverScope).ToString());
32 |
33 | Assert.That(tickAfterRefresh, Is.GreaterThan(tickBeforeRefresh));
34 | }
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/src/Coypu.Drivers.Tests/When_saving_screenshots.cs:
--------------------------------------------------------------------------------
1 | using System.Drawing;
2 | using System.IO;
3 | using NUnit.Framework;
4 | using Coypu.AcceptanceTests;
5 |
6 | namespace Coypu.Drivers.Tests
7 | {
8 | internal class When_saving_screenshots : DriverSpecs
9 | {
10 | [Test]
11 | public void SavesAScreenshot()
12 | {
13 | Scope driverScope = Root;
14 | Driver.Visit(PathHelper.GetPageHtmlPath("test-card.jpg"), driverScope);
15 | Driver.ResizeTo(new Size(800, 600), driverScope);
16 |
17 | string saveAs = Path.Combine(Path.GetTempPath(), "expect-saved-here.jpg");
18 | try
19 | {
20 | Driver.SaveScreenshot(saveAs, driverScope);
21 | Assert.That(File.Exists(saveAs), "Expected screenshot saved to " + new FileInfo(saveAs).FullName);
22 | }
23 | finally
24 | {
25 | if (File.Exists(saveAs))
26 | File.Delete(saveAs);
27 | }
28 | }
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/src/Coypu.Drivers.Tests/When_sending_keys_to_elements.cs:
--------------------------------------------------------------------------------
1 | using Shouldly;
2 | using NUnit.Framework;
3 |
4 | namespace Coypu.Drivers.Tests
5 | {
6 | internal class When_sending_keys_to_elements : DriverSpecs
7 | {
8 | [Test]
9 | public void Sets_value_of_text_input_field_with_id()
10 | {
11 | var textField = Field("containerLabeledTextInputFieldName");
12 | textField.Value.ShouldBe("text input field two val");
13 |
14 | Driver.SendKeys(textField, " - send keys without any click, clear first, etc");
15 |
16 | textField.Value.ShouldBe("text input field two val - send keys without any click, clear first, etc");
17 | }
18 | }
19 | }
--------------------------------------------------------------------------------
/src/Coypu.Drivers.Tests/When_uploading_files.cs:
--------------------------------------------------------------------------------
1 | using System.IO;
2 | using Shouldly;
3 | using NUnit.Framework;
4 |
5 | namespace Coypu.Drivers.Tests
6 | {
7 | internal class When_uploading_files : DriverSpecs
8 | {
9 | [Test]
10 | public void Sets_the_path_to_be_uploaded()
11 | {
12 | const string someLocalFile = @"local.file";
13 | try
14 | {
15 | var directoryInfo = new DirectoryInfo(Path.GetTempPath());
16 | var fullPath = Path.Combine(directoryInfo.FullName, someLocalFile);
17 | using (File.Create(fullPath))
18 | {
19 | }
20 |
21 | var textField = Field("forLabeledFileFieldId");
22 | Driver.Set(textField, fullPath);
23 |
24 | var findAgain = Field("forLabeledFileFieldId");
25 | findAgain.Value.ShouldEndWith(someLocalFile);
26 | }
27 | finally
28 | {
29 | File.Delete(someLocalFile);
30 | }
31 | }
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/src/Coypu.Drivers.Tests/html/frame1.htm:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | frame one title
6 |
7 |
8 | I am frame one
9 |
10 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/src/Coypu.Drivers.Tests/html/frame2.htm:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | frame two title
6 |
7 |
8 | I am frame two
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/src/Coypu.Drivers.Tests/html/frameset.htm:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
8 |
9 |
--------------------------------------------------------------------------------
/src/Coypu.Drivers.Tests/html/iFrame1.htm:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | iframe one title
6 |
7 |
8 | I am iframe one
9 |
10 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/src/Coypu.Drivers.Tests/html/iFrame2.htm:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | iframe two title
6 |
7 |
8 | I am iframe two
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/src/Coypu.Drivers.Tests/html/popUp.htm:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Pop Up Window
6 |
7 |
8 | I am a pop up window
9 |
10 |
17 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/src/Coypu.Drivers.Tests/html/popUp2.htm:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Pop Up Window 2
6 |
7 |
8 | I am a pop up window 2
9 |
10 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/src/Coypu.Drivers.Tests/html/table.htm:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Table
6 |
7 |
8 |
9 |
10 |
11 | Name |
12 | Age |
13 |
14 |
15 | Bob |
16 | 12 |
17 |
18 |
19 | Jane |
20 | 79 |
21 |
22 |
23 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/src/Coypu.Drivers.Tests/html/test-card.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/featurist/coypu/889ebb8d91b03d8fa7bd348cc0788d30d1c6b6c2/src/Coypu.Drivers.Tests/html/test-card.jpg
--------------------------------------------------------------------------------
/src/Coypu.Drivers.Tests/html/test-card.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/featurist/coypu/889ebb8d91b03d8fa7bd348cc0788d30d1c6b6c2/src/Coypu.Drivers.Tests/html/test-card.png
--------------------------------------------------------------------------------
/src/Coypu.NUnit/Coypu.NUnit.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 | {14FB5A97-D3A7-4759-BB6A-03CAFC9B8FAB}
4 | net6.0
5 | true
6 | Coypu.NUnit
7 | 4.2.0.0
8 | 4.2.0.0
9 | Coypu.NUnit
10 | 4.2.0
11 | NUnit matchers for Coypu.
12 | MIT
13 | https://github.com/featurist/coypu/
14 | Copyright © 2024 Adrian Longley and Contributors
15 | browser, automation, selenium, testing, nunit
16 | 7.3
17 | Adrian Longley, Jakub Obstarczyk
18 | Coypu
19 | https://github.com/featurist/coypu
20 | git
21 | en
22 | true
23 | true
24 | snupkg
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 | full
33 |
34 |
35 | pdbonly
36 |
37 |
38 | bin\Debug\Coypu.NUnit.xml
39 | bin\Debug\
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
--------------------------------------------------------------------------------
/src/Coypu.NUnit/Matchers/AggregateMatcher.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using NUnit.Framework.Constraints;
3 |
4 | namespace Coypu.NUnit.Matchers
5 | {
6 | public class AggregateMatcher : Constraint where T:Constraint
7 | {
8 | readonly IEnumerable _innerConstraints;
9 |
10 | public AggregateMatcher(IEnumerable innerConstraints)
11 | {
12 | _innerConstraints = innerConstraints;
13 |
14 | }
15 |
16 | public override ConstraintResult ApplyTo(TActual actual)
17 | {
18 | foreach (var innerConstraint in _innerConstraints)
19 | {
20 | var result = innerConstraint.ApplyTo(actual);
21 |
22 | if (!result.IsSuccess)
23 | {
24 | return new ConstraintResult(innerConstraint, result.ActualValue, false);
25 | }
26 | }
27 |
28 | return new ConstraintResult(this, actual, true);
29 | }
30 | }
31 | }
--------------------------------------------------------------------------------
/src/Coypu.NUnit/Matchers/HasContentMatcher.cs:
--------------------------------------------------------------------------------
1 | using System.Text.RegularExpressions;
2 | using NUnit.Framework.Constraints;
3 |
4 | namespace Coypu.NUnit.Matchers
5 | {
6 | public class HasContentMatcher : Constraint
7 | {
8 | private readonly string _expectedContent;
9 | private readonly Options _options;
10 | private string _actualContent;
11 |
12 | public HasContentMatcher(string expectedContent, Options options)
13 | {
14 | _expectedContent = expectedContent;
15 | _options = options;
16 | }
17 |
18 | public override ConstraintResult ApplyTo(TActual actual)
19 | {
20 | var scope = actual as DriverScope;
21 | var hasContent = scope.HasContent(_expectedContent, _options);
22 | if (!hasContent)
23 | {
24 | _actualContent = scope.Text;
25 | hasContent = _actualContent.Contains(_expectedContent);
26 | }
27 | return new ConstraintResult(this, actual, hasContent);
28 | }
29 |
30 | public override string Description => "Expected to find content: " + _expectedContent + "\nin:\n" + _actualContent;
31 | }
32 |
33 | public class HasContentMatchMatcher : Constraint
34 | {
35 | private readonly Regex _expectedContent;
36 | private readonly Options _options;
37 | private string _actualContent;
38 |
39 | public HasContentMatchMatcher(Regex expectedContent, Options options)
40 | {
41 | _expectedContent = expectedContent;
42 | _options = options;
43 | }
44 |
45 | public override ConstraintResult ApplyTo(TActual actual)
46 | {
47 | var scope = actual as DriverScope;
48 | var hasContent = scope.HasContentMatch(_expectedContent, _options);
49 | if (!hasContent)
50 | {
51 | _actualContent = scope.Text;
52 | hasContent = _expectedContent.IsMatch(_actualContent);
53 | }
54 | return new ConstraintResult(this, actual, hasContent);
55 | }
56 |
57 | public override string Description => "Expected to find content: " + _expectedContent + "\nin:\n" + _actualContent;
58 | }
59 | }
--------------------------------------------------------------------------------
/src/Coypu.NUnit/Matchers/HasNoContentMatcher.cs:
--------------------------------------------------------------------------------
1 | using NUnit.Framework.Constraints;
2 |
3 | namespace Coypu.NUnit.Matchers
4 | {
5 | public class HasNoContentMatcher : Constraint
6 | {
7 | private readonly string _expectedContent;
8 | private readonly Options _options;
9 | private string _actualContent;
10 |
11 | public HasNoContentMatcher(string expectedContent, Options options)
12 | {
13 | _expectedContent = expectedContent;
14 | _options = options;
15 | }
16 |
17 | public override ConstraintResult ApplyTo(TActual actual)
18 | {
19 | var scope = (Scope)actual;
20 | var hasNoContent = scope.HasNoContent(_expectedContent, _options);
21 | if (!hasNoContent)
22 | {
23 | _actualContent = scope.Now().Text;
24 | hasNoContent = !_actualContent.Contains(_expectedContent);
25 | }
26 |
27 | return new ConstraintResult(this, actual, hasNoContent);
28 | }
29 |
30 | public override string Description => "Expected NOT to find content: " + _expectedContent + "\nin:\n" + _actualContent;
31 | }
32 | }
--------------------------------------------------------------------------------
/src/Coypu.NUnit/Matchers/HasNoValueMatcher.cs:
--------------------------------------------------------------------------------
1 | using NUnit.Framework.Constraints;
2 |
3 | namespace Coypu.NUnit.Matchers
4 | {
5 | public class HasNoValueMatcher : Constraint
6 | {
7 | private readonly string _expectedContent;
8 | private readonly Options _options;
9 | private string _actualContent;
10 |
11 | public HasNoValueMatcher(string expectedContent, Options options)
12 | {
13 | _expectedContent = expectedContent;
14 | _options = options;
15 | }
16 |
17 | public override ConstraintResult ApplyTo(TActual actual)
18 | {
19 | var elementScope = actual as ElementScope;
20 | var hasNoValue = elementScope.HasNoValue(_expectedContent, _options);
21 | if (!hasNoValue)
22 | _actualContent = elementScope.Value;
23 | return new ConstraintResult(this, actual, hasNoValue);
24 | }
25 |
26 | public override string Description => "Expected NOT to find value: " + _expectedContent + "\nin:\n" + _actualContent;
27 | }
28 | }
--------------------------------------------------------------------------------
/src/Coypu.NUnit/Matchers/HasValueMatcher.cs:
--------------------------------------------------------------------------------
1 | using NUnit.Framework.Constraints;
2 |
3 | namespace Coypu.NUnit.Matchers
4 | {
5 | public class HasValueMatcher : Constraint
6 | {
7 | private readonly string _expectedContent;
8 | private readonly Options _options;
9 | private string _actualContent;
10 |
11 | public HasValueMatcher(string expectedContent, Options options)
12 | {
13 | _expectedContent = expectedContent;
14 | _options = options;
15 | }
16 |
17 | public override ConstraintResult ApplyTo(TActual actual)
18 | {
19 | var elementScope = actual as ElementScope;
20 | var hasValue = elementScope.HasValue(_expectedContent, _options);
21 | if (!hasValue)
22 | {
23 | _actualContent = elementScope.Value;
24 | hasValue = _actualContent == _expectedContent;
25 | }
26 | return new ConstraintResult(this, actual, hasValue);
27 | }
28 |
29 | public override string Description => "Expected to find value: " + _expectedContent + "\nin:\n" + _actualContent;
30 | }
31 | }
--------------------------------------------------------------------------------
/src/Coypu.Tests/Coypu.Tests.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 | {3ACF8A72-2EAB-42E7-B60E-BB781D3B0DB2}
4 | net6.0
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 | PreserveNewest
23 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/src/Coypu.Tests/TestBuilders/FindsFirstWitNoDisambiguationStrategy.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Data;
4 | using System.Linq;
5 | using Coypu.Finders;
6 |
7 | namespace Coypu.Tests.TestBuilders
8 | {
9 | public class FirstOrDefaultNoDisambiguationStrategy : DisambiguationStrategy
10 | {
11 | public Element ResolveQuery(ElementFinder elementFinder)
12 | {
13 | return elementFinder.Find(elementFinder.Options).FirstOrDefault();
14 | }
15 | }
16 |
17 | public class ThrowsWhenMissingButNoDisambiguationStrategy : DisambiguationStrategy
18 | {
19 | public Element ResolveQuery(ElementFinder elementFinder)
20 | {
21 | var all = elementFinder.Find(elementFinder.Options);
22 | var array = AsArray(all, elementFinder);
23 | if (!array.Any())
24 | throw elementFinder.GetMissingException();
25 |
26 | return all.First();
27 | }
28 |
29 | private static Element[] AsArray(IEnumerable all, ElementFinder elementFinder)
30 | {
31 | try {
32 | return all.ToArray();
33 | }
34 | catch(InvalidOperationException) {
35 | // Elements have changed due to async page behaviour
36 | throw elementFinder.GetMissingException();
37 | }
38 | }
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/src/Coypu.Tests/TestBuilders/TestSessionBuilder.cs:
--------------------------------------------------------------------------------
1 | using Coypu.Timing;
2 | using Coypu.Tests.When_interacting_with_the_browser;
3 | using Coypu.WebRequests;
4 |
5 | namespace Coypu.Tests.TestBuilders
6 | {
7 | internal class TestSessionBuilder
8 | {
9 | internal static BrowserSession Build(SessionConfiguration sessionConfiguration,
10 | IDriver driver,
11 | TimingStrategy timingStrategy,
12 | Waiter waiter,
13 | RestrictedResourceDownloader restrictedResourceDownloader,
14 | UrlBuilder urlBuilder,
15 | DisambiguationStrategy disambiguationStrategy = null)
16 | {
17 | disambiguationStrategy = disambiguationStrategy ?? new FirstOrDefaultNoDisambiguationStrategy();
18 |
19 | return new BrowserSession(sessionConfiguration,
20 | new StubDriverFactory(driver),
21 | timingStrategy,
22 | waiter,
23 | urlBuilder,
24 | disambiguationStrategy,
25 | restrictedResourceDownloader);
26 | }
27 | }
28 | }
--------------------------------------------------------------------------------
/src/Coypu.Tests/TestDoubles/ImmediateSingleExecutionFakeTimingStrategy.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Coypu.Actions;
3 | using Coypu.Queries;
4 | using Coypu.Timing;
5 |
6 | namespace Coypu.Tests.TestDoubles
7 | {
8 | public class ImmediateSingleExecutionFakeTimingStrategy : TimingStrategy
9 | {
10 | public T Synchronise(Query query)
11 | {
12 | return query.Run();
13 | }
14 |
15 | public void TryUntil(BrowserAction tryThis, PredicateQuery until, Options options)
16 | {
17 | tryThis.Act();
18 | }
19 |
20 | public bool ZeroTimeout{get; set; }
21 | public void SetOverrideTimeout(TimeSpan timeout)
22 | {
23 | }
24 |
25 | public void ClearOverrideTimeout()
26 | {
27 | }
28 | }
29 | }
--------------------------------------------------------------------------------
/src/Coypu.Tests/TestDoubles/SpyRestrictedResourceDownloader.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using System.Net;
3 | using Coypu.WebRequests;
4 |
5 | namespace Coypu.Tests.TestDoubles
6 | {
7 | public class SpyRestrictedResourceDownloader : RestrictedResourceDownloader
8 | {
9 | private readonly IList downloadedFiles = new List();
10 |
11 | public IList DownloadedFiles
12 | {
13 | get { return downloadedFiles; }
14 | }
15 |
16 | public void SetCookies(IEnumerable cookies)
17 | {
18 | this.Cookies = cookies;
19 | }
20 |
21 | protected IEnumerable Cookies { get; private set; }
22 |
23 | public void DownloadFile(string resource, string saveAs)
24 | {
25 | DownloadedFiles.Add(new DownloadedFile(resource, saveAs, Cookies));
26 | }
27 | }
28 |
29 | public class DownloadedFile
30 | {
31 | public string Resource { get; private set; }
32 | public string SaveAs { get; private set; }
33 | public IEnumerable Cookies { get; set; }
34 |
35 | public DownloadedFile(string resource, string saveAs, IEnumerable cookies)
36 | {
37 | Resource = resource;
38 | SaveAs = saveAs;
39 | Cookies = cookies;
40 | }
41 | }
42 | }
--------------------------------------------------------------------------------
/src/Coypu.Tests/TestDoubles/StubElement.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | namespace Coypu.Tests.TestDoubles
3 | {
4 | public class StubElement : Element
5 | {
6 | private readonly Dictionary attributes = new Dictionary();
7 |
8 | public string Id { get; set; }
9 |
10 | public string Text { get; set; }
11 |
12 | public string Value { get; set; }
13 |
14 | public string Name { get; set; }
15 |
16 | public string InnerHTML { get; set; }
17 |
18 | public string Title { get; set; }
19 |
20 | public bool Disabled { get; set; }
21 |
22 | public string OuterHTML { get; set; }
23 |
24 | public string SelectedOption { get; set; }
25 |
26 | public bool Selected { get; set; }
27 |
28 | public object Native { get; set; }
29 |
30 | public string this[string attributeName]
31 | {
32 | get
33 | {
34 | return attributes.ContainsKey(attributeName) ? attributes[attributeName] : string.Empty;
35 | }
36 | }
37 |
38 | public void StubAttribute(string attributeName, string value)
39 | {
40 | attributes[attributeName] = value;
41 | }
42 | }
43 | }
--------------------------------------------------------------------------------
/src/Coypu.Tests/TestDoubles/StubWebResources.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using System.Net;
3 |
4 | namespace Coypu.Tests.TestDoubles
5 | {
6 | public class StubWebResources
7 | {
8 | private readonly Dictionary resources = new Dictionary();
9 |
10 | public void StubResource(string resource, StubWebResponse stubWebResponse)
11 | {
12 | resources[resource] = stubWebResponse;
13 | }
14 |
15 | public WebResponse Get(string resource)
16 | {
17 | if (!resources.ContainsKey(resource))
18 | throw new System.ArgumentException("There was no resource at " + resource, "resource");
19 |
20 | return resources[resource];
21 | }
22 | }
23 | }
--------------------------------------------------------------------------------
/src/Coypu.Tests/TestDoubles/StubWebResponse.cs:
--------------------------------------------------------------------------------
1 | using System.IO;
2 | using System.Net;
3 |
4 | namespace Coypu.Tests.TestDoubles
5 | {
6 | public class StubWebResponse : WebResponse
7 | {
8 | private readonly Stream responseStream = new MemoryStream();
9 |
10 | public override Stream GetResponseStream()
11 | {
12 | return responseStream;
13 | }
14 |
15 | public override void Close()
16 | {
17 | responseStream.Dispose();
18 | base.Close();
19 | }
20 | }
21 | }
--------------------------------------------------------------------------------
/src/Coypu.Tests/TestException.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace Coypu.Tests
4 | {
5 | public class TestException : Exception
6 | {
7 | public TestException(string message) : base(message)
8 | {
9 | }
10 | }
11 | }
--------------------------------------------------------------------------------
/src/Coypu.Tests/When_applying_match_strategy/Any_match_strategy.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using Coypu.Finders;
4 |
5 | namespace Coypu.Tests.When_applying_match_strategy
6 | {
7 | public abstract class Any_match_strategy
8 | {
9 | public abstract Match Match {get;}
10 | public abstract TextPrecision TextPrecision {get;}
11 |
12 | public Options FinderOptions()
13 | {
14 | return new Options
15 | {
16 | Match = this.Match,
17 | TextPrecision = this.TextPrecision,
18 | // Some other stuff to check they are merged
19 | ConsiderInvisibleElements = true,
20 | RetryInterval = TimeSpan.FromMilliseconds(4321)
21 | };
22 | }
23 |
24 | protected static void StubExactResults(StubElementFinder finder, Options finderOptions, IEnumerable exactResults)
25 | {
26 | finder.StubbedFindResults[Options.Merge(Options.Exact,finderOptions)] = exactResults;
27 | }
28 |
29 | protected static void StubSubstringResults(StubElementFinder finder, Options finderOptions, IEnumerable exactResults)
30 | {
31 | finder.StubbedFindResults[Options.Merge(Options.Substring, finderOptions)] = exactResults;
32 | }
33 |
34 | protected static Element ResolveQuery(StubElementFinder finder)
35 | {
36 | var strategy = new FinderOptionsDisambiguationStrategy();
37 | var results = strategy.ResolveQuery(finder);
38 | return results;
39 | }
40 | }
41 | }
--------------------------------------------------------------------------------
/src/Coypu.Tests/When_applying_match_strategy/StubElementFinder.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using Coypu.Finders;
3 |
4 | namespace Coypu.Tests.When_applying_match_strategy
5 | {
6 | public class StubElementFinder : ElementFinder
7 | {
8 | private readonly bool _supportsSubstringTextMatching;
9 | private readonly string _queryDescription;
10 |
11 | public IDictionary> StubbedFindResults = new Dictionary>();
12 |
13 | public StubElementFinder(Options options, bool supportsSubstringTextMatching = true, string queryDescription = null) : base(null, null, null, options)
14 | {
15 | _supportsSubstringTextMatching = supportsSubstringTextMatching;
16 | _queryDescription = queryDescription;
17 | }
18 |
19 | public override bool SupportsSubstringTextMatching
20 | {
21 | get { return _supportsSubstringTextMatching; }
22 | }
23 |
24 | internal override IEnumerable Find(Options options)
25 | {
26 | return StubbedFindResults[options];
27 | }
28 |
29 | internal override string QueryDescription
30 | {
31 | get { return _queryDescription; }
32 | }
33 | }
34 | }
--------------------------------------------------------------------------------
/src/Coypu.Tests/When_applying_match_strategy/When_using_first_exact.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using System.Linq;
3 | using Coypu.Tests.TestDoubles;
4 | using NUnit.Framework;
5 |
6 | namespace Coypu.Tests.When_applying_match_strategy
7 | {
8 | public class When_using_first_exact : Any_match_strategy
9 | {
10 | public override Match Match
11 | {
12 | get { return Match.First; }
13 | }
14 |
15 | public override TextPrecision TextPrecision
16 | {
17 | get { return TextPrecision.Exact; }
18 | }
19 |
20 | [Test]
21 | public void When_there_is_more_than_one_match_it_picks_the_first_one()
22 | {
23 | var finderOptions = FinderOptions();
24 | var finder = new StubElementFinder(finderOptions);
25 | var exactResults = new List { new StubElement(), new StubElement() };
26 |
27 | StubExactResults(finder, finderOptions, exactResults);
28 |
29 | var results = ResolveQuery(finder);
30 |
31 | Assert.That(results, Is.SameAs(exactResults.First()));
32 | }
33 |
34 |
35 | [Test]
36 | public void When_there_are_no_exact_matches_it_throws_missing_exception_and_only_looks_for_exact()
37 | {
38 | var finderOptions = FinderOptions();
39 | var finder = new StubElementFinder(finderOptions, queryDescription: "something from StubElementFinder");
40 |
41 | StubExactResults(finder, finderOptions, new List());
42 |
43 | try
44 | {
45 | ResolveQuery(finder);
46 | Assert.Fail("Expected missing html exception");
47 | }
48 | catch (MissingHtmlException ex)
49 | {
50 | Assert.That(ex.Message, Is.EqualTo("Unable to find something from StubElementFinder"));
51 | }
52 | }
53 | }
54 | }
--------------------------------------------------------------------------------
/src/Coypu.Tests/When_applying_match_strategy/When_using_first_substring.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using Coypu.Tests.TestDoubles;
5 | using NUnit.Framework;
6 |
7 | namespace Coypu.Tests.When_applying_match_strategy
8 | {
9 | public class When_using_first_substring : Any_match_strategy
10 | {
11 | public override Match Match
12 | {
13 | get { return Match.First; }
14 | }
15 |
16 | public override TextPrecision TextPrecision
17 | {
18 | get { return TextPrecision.Substring; }
19 | }
20 |
21 | [Test]
22 | public void When_there_is_more_than_one_substring_match_it_picks_the_first_one()
23 | {
24 | var finderOptions = FinderOptions();
25 | var finder = new StubElementFinder(finderOptions);
26 | var exactResults = new List { new StubElement(), new StubElement() };
27 |
28 | StubSubstringResults(finder, finderOptions, exactResults);
29 |
30 | var results = ResolveQuery(finder);
31 |
32 | Assert.That(results, Is.SameAs(exactResults.First()));
33 | }
34 |
35 | [Test]
36 | public void When_there_are_no_substring_matches_it_throws_missing_exception()
37 | {
38 | var finderOptions = FinderOptions();
39 | var finder = new StubElementFinder(finderOptions, queryDescription: "something from StubElementFinder");
40 |
41 | StubSubstringResults(finder, finderOptions, new List());
42 |
43 | try
44 | {
45 | ResolveQuery(finder);
46 | Assert.Fail("Expected missing html exception");
47 | }
48 | catch (MissingHtmlException ex)
49 | {
50 | Assert.That(ex.Message, Is.EqualTo("Unable to find something from StubElementFinder"));
51 | }
52 | }
53 | }
54 |
55 | }
--------------------------------------------------------------------------------
/src/Coypu.Tests/When_interacting_with_the_browser/When_constructing_xpath.cs:
--------------------------------------------------------------------------------
1 | using Coypu.Drivers;
2 | using NUnit.Framework;
3 |
4 | namespace Coypu.Tests.When_interacting_with_the_browser
5 | {
6 | [TestFixture]
7 | public class When_constructing_xpath
8 | {
9 | [Test]
10 | public void It_handles_double_and_single_quotes_with_concat()
11 | {
12 | It_handles_double_and_single_quotes_with_concat("foo", "\"foo\""); // no quotes
13 | It_handles_double_and_single_quotes_with_concat("\"foo", "'\"foo'"); // double quotes only
14 | It_handles_double_and_single_quotes_with_concat("'foo", "\"'foo\""); // single quotes only
15 | It_handles_double_and_single_quotes_with_concat("'foo\"bar", "concat(\"'foo\", '\"', \"bar\")"); // both; double quotes in mid-string
16 | It_handles_double_and_single_quotes_with_concat("'foo\"bar\"baz", "concat(\"'foo\", '\"', \"bar\", '\"', \"baz\")"); // multiple double quotes in mid-string
17 | It_handles_double_and_single_quotes_with_concat("'foo\"", "concat(\"'foo\", '\"')"); // string ends with double quotes
18 | It_handles_double_and_single_quotes_with_concat("'foo\"\"", "concat(\"'foo\", '\"', '\"')"); // string ends with run of double quotes
19 | It_handles_double_and_single_quotes_with_concat("\"'foo", "concat('\"', \"'foo\")"); // string begins with double quotes
20 | It_handles_double_and_single_quotes_with_concat("\"\"'foo", "concat('\"', '\"', \"'foo\")"); // string begins with run of double quotes
21 | It_handles_double_and_single_quotes_with_concat("'foo\"\"bar", "concat(\"'foo\", '\"', '\"', \"bar\")"); // run of double quotes in mid-string
22 | }
23 |
24 | public void It_handles_double_and_single_quotes_with_concat(string input, string escaped)
25 | {
26 | Assert.That(new XPath().Literal(input), Is.EqualTo(escaped));
27 | }
28 |
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/src/Coypu.Tests/When_interacting_with_the_browser/When_controlling_the_window.cs:
--------------------------------------------------------------------------------
1 | using System.Linq;
2 | using NUnit.Framework;
3 |
4 | namespace Coypu.Tests.When_interacting_with_the_browser
5 | {
6 | [TestFixture]
7 | public class When_controlling_the_window : BrowserInteractionTests
8 | {
9 | [Test]
10 | public void MaximiseWindow_acts_immediately_on_driver()
11 | {
12 | var mainWindow = browserSession;
13 | mainWindow.MaximiseWindow();
14 |
15 | Assert.That(driver.MaximiseWindowCalls.Single(), Is.SameAs(mainWindow));
16 | }
17 |
18 | [Test]
19 | public void MaximiseWindow_acts_on_current_scope()
20 | {
21 | popupScope.MaximiseWindow();
22 |
23 | Assert.That(driver.MaximiseWindowCalls.Single(), Is.SameAs(popupScope));
24 | }
25 |
26 | [Test]
27 | public void ResizeWindow_acts_immediately_on_driver()
28 | {
29 | var mainWindow = browserSession;
30 | mainWindow.ResizeTo(500, 600);
31 |
32 | Assert.That(driver.ResizeToCalls.Single().Request.Width, Is.EqualTo(500));
33 | Assert.That(driver.ResizeToCalls.Single().Request.Height, Is.EqualTo(600));
34 | Assert.That(driver.ResizeToCalls.Single().Scope, Is.SameAs(mainWindow));
35 | }
36 |
37 | [Test]
38 | public void ResizeWindow_acts_on_current_scope()
39 | {
40 | popupScope.ResizeTo(500, 600);
41 |
42 | Assert.That(driver.ResizeToCalls.Single().Scope, Is.SameAs(popupScope));
43 | }
44 | }
45 | }
--------------------------------------------------------------------------------
/src/Coypu.Tests/When_interacting_with_the_browser/When_executing_script.cs:
--------------------------------------------------------------------------------
1 | using NUnit.Framework;
2 |
3 | namespace Coypu.Tests.When_interacting_with_the_browser
4 | {
5 | [TestFixture]
6 | public class When_executing_script : BrowserInteractionTests
7 | {
8 | [Test]
9 | public void Visit_passes_message_directly_to_the_driver_returning_response_immediately()
10 | {
11 | const string script = "document.getElementById('asdf').click();";
12 | const string expectedReturnValue = "script return value";
13 |
14 | driver.StubExecuteScript(script, expectedReturnValue, browserSession);
15 |
16 | Assert.That(browserSession.ExecuteScript(script), Is.EqualTo(expectedReturnValue));
17 | }
18 | }
19 | }
--------------------------------------------------------------------------------
/src/Coypu.Tests/When_interacting_with_the_browser/When_finding_then_checking_an_element.cs:
--------------------------------------------------------------------------------
1 | using System.Linq;
2 | using Coypu.Tests.TestDoubles;
3 | using NUnit.Framework;
4 |
5 | namespace Coypu.Tests.When_interacting_with_the_browser {
6 | [TestFixture]
7 | public class When_finding_then_checking_an_element : BrowserInteractionTests
8 | {
9 | [Test]
10 | public void It_finds_then_synchronises_check_element_on_underlying_driver()
11 | {
12 | var element = new StubElement();
13 | driver.StubId("something_to_click", element, browserSession, sessionConfiguration);
14 | SpyTimingStrategy.AlwaysReturnFromSynchronise(element);
15 |
16 | var toCheck = browserSession.FindCss("something_to_click");
17 |
18 | toCheck.Check();
19 |
20 | Assert.That(driver.CheckedElements, Has.No.Member(toCheck), "Check was not synchronised");
21 |
22 | RunQueryAndCheckTiming();
23 |
24 | Assert.That(driver.CheckedElements, Has.Member(toCheck));
25 | }
26 | }
27 | }
--------------------------------------------------------------------------------
/src/Coypu.Tests/When_interacting_with_the_browser/When_finding_then_clicking_an_element.cs:
--------------------------------------------------------------------------------
1 | using System.Linq;
2 | using Coypu.Tests.TestDoubles;
3 | using NUnit.Framework;
4 |
5 | namespace Coypu.Tests.When_interacting_with_the_browser {
6 | [TestFixture]
7 | public class When_finding_then_clicking_an_element_ : BrowserInteractionTests
8 | {
9 | [Test]
10 | public void It_finds_then_synchronises_click_element_on_underlying_driver()
11 | {
12 | var element = new StubElement();
13 | driver.StubId("something_to_click", element, browserSession, sessionConfiguration);
14 | SpyTimingStrategy.AlwaysReturnFromSynchronise(element);
15 |
16 | var elementScope = browserSession.FindId("something_to_click");
17 | elementScope.Click();
18 |
19 | Assert.That(driver.ClickedElements, Has.No.Member(elementScope), "Click was not synchronised");
20 |
21 | RunQueryAndCheckTiming();
22 |
23 | Assert.That(driver.ClickedElements, Has.Member(elementScope));
24 | }
25 | }
26 | }
--------------------------------------------------------------------------------
/src/Coypu.Tests/When_interacting_with_the_browser/When_finding_then_filling_in_any_field.cs:
--------------------------------------------------------------------------------
1 | using System.Linq;
2 | using Coypu.Tests.TestDoubles;
3 | using NUnit.Framework;
4 |
5 | namespace Coypu.Tests.When_interacting_with_the_browser {
6 | [TestFixture]
7 | public class When_finding_then_filling_in_any_field : BrowserInteractionTests
8 | {
9 | [Test]
10 | public void It_makes_robust_call_to_find_then_clicks_element_on_underlying_driver()
11 | {
12 | var element = new StubElement();
13 | driver.StubId("something_to_fill_in", element, browserSession, sessionConfiguration);
14 | SpyTimingStrategy.AlwaysReturnFromSynchronise(element);
15 |
16 | var elementScope = browserSession.FindId("something_to_fill_in");
17 |
18 | elementScope.FillInWith("some filled in stuff");
19 |
20 | Assert.That(driver.SetFields.Keys, Has.No.Member(elementScope));
21 |
22 | RunQueryAndCheckTiming();
23 |
24 | Assert.That(driver.SetFields.Keys, Has.Member(elementScope));
25 | Assert.That(driver.SetFields[elementScope].Value, Is.EqualTo("some filled in stuff"));
26 | }
27 | }
28 | }
--------------------------------------------------------------------------------
/src/Coypu.Tests/When_interacting_with_the_browser/When_finding_then_hovering.cs:
--------------------------------------------------------------------------------
1 | using System.Linq;
2 | using Coypu.Tests.TestDoubles;
3 | using NUnit.Framework;
4 |
5 | namespace Coypu.Tests.When_interacting_with_the_browser
6 | {
7 | [TestFixture]
8 | public class When_finding_then_hovering : BrowserInteractionTests
9 | {
10 | [Test]
11 | public void It_makes_robust_call_to_find_then_hover_element_on_underlying_driver()
12 | {
13 | var element = new StubElement();
14 | driver.StubId("something_to_hover", element, browserSession, sessionConfiguration);
15 | SpyTimingStrategy.AlwaysReturnFromSynchronise(element);
16 |
17 | browserSession.FindId("something_to_hover").Hover();
18 |
19 | Assert.That(driver.HoveredElements, Has.No.Member(element));
20 |
21 | RunQueryAndCheckTiming();
22 |
23 | Assert.That(driver.HoveredElements, Has.Member(element));
24 | }
25 | }
26 | }
--------------------------------------------------------------------------------
/src/Coypu.Tests/When_interacting_with_the_browser/When_finding_then_unchecking_any_element.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Linq;
3 | using Coypu.Tests.TestDoubles;
4 | using NUnit.Framework;
5 |
6 | namespace Coypu.Tests.When_interacting_with_the_browser
7 | {
8 | [TestFixture]
9 | public class When_finding_then_unchecking_any_element : BrowserInteractionTests
10 | {
11 | [Test]
12 | public void It_makes_robust_call_to_find_then_clicks_element_on_underlying_driver()
13 | {
14 | var element = new StubElement();
15 | driver.StubId("something_to_click", element, browserSession, sessionConfiguration);
16 | SpyTimingStrategy.AlwaysReturnFromSynchronise(element);
17 |
18 | var toCheck = browserSession.FindCss("something_to_click");
19 |
20 | toCheck.Uncheck();
21 |
22 | Assert.That(driver.UncheckedElements, Has.No.Member(toCheck), "Uncheck was not synchronised");
23 |
24 | RunQueryAndCheckTiming();
25 |
26 | Assert.That(driver.UncheckedElements, Has.Member(toCheck));
27 | }
28 | }
29 | }
--------------------------------------------------------------------------------
/src/Coypu.Tests/When_interacting_with_the_browser/When_inspecting_location.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using NUnit.Framework;
3 |
4 | namespace Coypu.Tests.When_interacting_with_the_browser
5 | {
6 | [TestFixture]
7 | public class When_inspecting_location : BrowserInteractionTests
8 | {
9 | [Test]
10 | public void It_returns_the_driver_url()
11 | {
12 | var driverLocation = new Uri("https://blank.org:8080/actual_location");
13 | driver.StubLocation(driverLocation,browserSession);
14 | Assert.That(browserSession.Location, Is.EqualTo(driverLocation));
15 | }
16 | }
17 | }
--------------------------------------------------------------------------------
/src/Coypu.Tests/When_interacting_with_the_browser/When_inspecting_modal_dialogs.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using NUnit.Framework;
3 |
4 | namespace Coypu.Tests.When_interacting_with_the_browser
5 | {
6 | [TestFixture]
7 | public class When_inspecting_modal_dialogs : When_inspecting
8 | {
9 | [Test]
10 | public void HasDialog_should_wait_for_robustly_Positive_example()
11 | {
12 | Queries_robustly(true, browserSession.HasDialog, driver.StubDialog);
13 | }
14 |
15 | [Test]
16 | public void HasDialog_should_wait_for_robustly_Negative_example()
17 | {
18 | Queries_robustly(false, browserSession.HasDialog, driver.StubDialog);
19 | }
20 |
21 | [Test]
22 | public void HasNoDialog_should_wait_for_robustly_Positive_example()
23 | {
24 | Queries_robustly_reversing_result(true, browserSession.HasNoDialog, driver.StubDialog);
25 | }
26 |
27 | [Test]
28 | public void HasNoDialog_should_wait_for_robustly_Negative_example()
29 | {
30 | Queries_robustly_reversing_result(false, browserSession.HasNoDialog, driver.StubDialog);
31 | }
32 | }
33 | }
--------------------------------------------------------------------------------
/src/Coypu.Tests/When_interacting_with_the_browser/When_inspecting_title.cs:
--------------------------------------------------------------------------------
1 | using NUnit.Framework;
2 |
3 | namespace Coypu.Tests.When_interacting_with_the_browser
4 | {
5 | [TestFixture]
6 | public class When_inspecting_title : BrowserInteractionTests
7 | {
8 | [Test]
9 | public void It_returns_the_driver_page_title()
10 | {
11 | var pageTitle = "Coypu interaction tests page";
12 | driver.StubTitle(pageTitle, browserSession);
13 | Assert.That(browserSession.Title, Is.EqualTo(pageTitle));
14 | }
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/src/Coypu.Tests/When_interacting_with_the_browser/When_interacting_with_modal_dialogs.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Linq;
3 | using NUnit.Framework;
4 |
5 | namespace Coypu.Tests.When_interacting_with_the_browser
6 | {
7 | [TestFixture]
8 | public class When_interacting_with_modal_dialogs : BrowserInteractionTests
9 | {
10 | [Test]
11 | public void AcceptDialog_should_make_robust_call_to_underlying_driver()
12 | {
13 | browserSession.AcceptModalDialog();
14 |
15 | Assert.That(driver.ModalDialogsAccepted.Any(), Is.False);
16 | RunQueryAndCheckTiming();
17 | Assert.That(driver.ModalDialogsAccepted.Single(), Is.SameAs(browserSession));
18 | }
19 |
20 | [Test]
21 | public void CancelDialog_should_make_robust_call_to_underlying_driver()
22 | {
23 | browserSession.CancelModalDialog();
24 |
25 | Assert.That(driver.ModalDialogsCancelled.Any(), Is.False);
26 | RunQueryAndCheckTiming();
27 | Assert.That(driver.ModalDialogsCancelled.Single(), Is.SameAs(browserSession));
28 | }
29 |
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/src/Coypu.Tests/When_interacting_with_the_browser/When_saving_screenshots.cs:
--------------------------------------------------------------------------------
1 | using System.Linq;
2 | using NUnit.Framework;
3 |
4 | namespace Coypu.Tests.When_interacting_with_the_browser
5 | {
6 | [TestFixture]
7 | public class When_saving_screenshots : BrowserInteractionTests
8 | {
9 | [Test]
10 | public void TakeScreenshot_acts_immediately_on_driver()
11 | {
12 | TakeScreenshot_acts_immediately_on_driver(popupScope);
13 | }
14 |
15 | [Test]
16 | public void TakeScreenshot_uses_current_window_scope()
17 | {
18 | TakeScreenshot_acts_immediately_on_driver(popupScope);
19 | }
20 |
21 | private void TakeScreenshot_acts_immediately_on_driver(BrowserWindow mainWindow)
22 | {
23 | mainWindow.SaveScreenshot("save-me-here.png");
24 |
25 | var saveScreenshotCall = driver.SaveScreenshotCalls.Single();
26 |
27 | Assert.That(saveScreenshotCall.Request, Is.EqualTo("save-me-here.png"));
28 |
29 | Assert.That(saveScreenshotCall.Scope, Is.EqualTo(mainWindow));
30 | }
31 | }
32 | }
--------------------------------------------------------------------------------
/src/Coypu.Tests/When_interacting_with_the_browser/When_scoping_interactions.cs:
--------------------------------------------------------------------------------
1 | using Coypu.Tests.TestBuilders;
2 | using Coypu.Tests.TestDoubles;
3 | using NUnit.Framework;
4 |
5 | namespace Coypu.Tests.When_interacting_with_the_browser
6 | {
7 | [TestFixture]
8 | public class When_scoping_interactions : BrowserInteractionTests
9 | {
10 | [Test]
11 | public void It_sets_the_scope_on_the_driver()
12 | {
13 | browserSession = TestSessionBuilder.Build(new SessionConfiguration(), driver, new ImmediateSingleExecutionFakeTimingStrategy(), fakeWaiter, null, stubUrlBuilder);
14 | var section = new StubElement();
15 | var expectedLink = new StubElement();
16 | driver.StubId("some_section", section, browserSession, sessionConfiguration);
17 |
18 | var innerScope = browserSession.FindSection("some section");
19 |
20 | driver.StubId("some_element", expectedLink, innerScope, sessionConfiguration);
21 |
22 | var actualLink = innerScope.FindId("some_element").Now();
23 |
24 | Assert.That(actualLink, Is.SameAs(expectedLink));
25 |
26 | }
27 | }
28 | }
--------------------------------------------------------------------------------
/src/Coypu.Tests/When_interacting_with_the_browser/When_visiting.cs:
--------------------------------------------------------------------------------
1 | using System.Linq;
2 | using NUnit.Framework;
3 |
4 | namespace Coypu.Tests.When_interacting_with_the_browser
5 | {
6 | [TestFixture]
7 | public class When_visiting : BrowserInteractionTests
8 | {
9 | [Test]
10 | public void It_uses_a_fully_qualified_url_from_the_url_builder()
11 | {
12 | stubUrlBuilder.SetStubUrl("/some/resource", "http://blank.org");
13 | browserSession.Visit("/some/resource");
14 | Assert.That(driver.Visits.Single().Request, Is.EqualTo("http://blank.org"));
15 | Assert.That(driver.Visits.Single().Scope, Is.EqualTo(browserSession));
16 | }
17 |
18 | [Test]
19 | public void It_uses_the_current_scope()
20 | {
21 | stubUrlBuilder.SetStubUrl("/some/resource", "http://blank.org");
22 | popupScope.Visit("/some/resource");
23 |
24 | Assert.That(driver.Visits.Single().Request, Is.EqualTo("http://blank.org"));
25 | Assert.That(driver.Visits.Single().Scope, Is.EqualTo(popupScope));
26 | }
27 | }
28 | }
--------------------------------------------------------------------------------
/src/Coypu.Tests/When_making_browser_interactions_robust/TestActions.cs:
--------------------------------------------------------------------------------
1 | using Coypu.Actions;
2 |
3 | namespace Coypu.Tests.When_making_browser_interactions_robust
4 | {
5 | public class CountTriesAction : BrowserAction
6 | {
7 | public CountTriesAction(Options options) : base(null, options)
8 | {
9 | }
10 |
11 | public int Tries { get; private set; }
12 |
13 | public override void Act()
14 | {
15 | Tries++;
16 | }
17 | }
18 | }
--------------------------------------------------------------------------------
/src/Coypu.Tests/When_making_browser_interactions_robust/When_waiting.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Diagnostics;
3 | using Coypu.Timing;
4 | using NUnit.Framework;
5 |
6 | namespace Coypu.Tests.When_making_browser_interactions_robust
7 | {
8 | [TestFixture]
9 | public class When_waiting
10 | {
11 | public const int AccuracyMilliseconds = 40;
12 |
13 | [Test]
14 | public void It_sleeps_for_the_expected_time_Case_1()
15 | {
16 | It_sleeps_for_the_expected_time(100);
17 | }
18 |
19 | [Test]
20 | public void It_sleeps_for_the_expected_time_Case_2()
21 | {
22 | It_sleeps_for_the_expected_time(200);
23 | }
24 |
25 | public void It_sleeps_for_the_expected_time(int expectedDurationMilliseconds)
26 | {
27 | var waiter = new StopwatchWaiter();
28 | var stopWatch = Stopwatch.StartNew();
29 | var expectedDuration = TimeSpan.FromMilliseconds(expectedDurationMilliseconds);
30 |
31 | waiter.Wait(expectedDuration);
32 |
33 | var actualWait = stopWatch.ElapsedMilliseconds;
34 |
35 | const int toleranceMilliseconds = AccuracyMilliseconds;
36 |
37 | Assert.That((int)actualWait, Is.InRange(expectedDurationMilliseconds - toleranceMilliseconds,
38 | expectedDurationMilliseconds + toleranceMilliseconds));
39 | }
40 |
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/src/Coypu.Tests/When_starting_and_ending_sessions.cs:
--------------------------------------------------------------------------------
1 | using Coypu.Tests.TestDoubles;
2 | using NUnit.Framework;
3 |
4 | namespace Coypu.Tests
5 | {
6 | [TestFixture]
7 | public class When_starting_and_ending_sessions
8 | {
9 | private SessionConfiguration SessionConfiguration;
10 |
11 | [SetUp]
12 | public void SetUp()
13 | {
14 | SessionConfiguration = new SessionConfiguration();
15 | SessionConfiguration.Driver = typeof (FakeDriver);
16 | }
17 |
18 | [Test]
19 | public void Dispose_handles_a_disposed_session()
20 | {
21 | var browserSession = new BrowserSession(SessionConfiguration);
22 |
23 | browserSession.Dispose();
24 | browserSession.Dispose();
25 | }
26 |
27 | [Test]
28 | public void A_session_gets_its_driver_from_config()
29 | {
30 | SessionConfiguration.Driver = typeof (FakeDriver);
31 | using (var browserSession = new BrowserSession(SessionConfiguration))
32 | {
33 | Assert.That(browserSession.Driver, Is.TypeOf(typeof(FakeDriver)));
34 | }
35 |
36 | SessionConfiguration.Driver = typeof(StubDriver);
37 | using (var browserSession = new BrowserSession(SessionConfiguration))
38 | {
39 | Assert.That(browserSession.Driver, Is.TypeOf(typeof(StubDriver)));
40 | }
41 | }
42 |
43 | [Test]
44 | public void Session_exposes_native_driver_if_you_really_need_it()
45 | {
46 | using (var browserSession = new BrowserSession(SessionConfiguration))
47 | {
48 | Assert.That(browserSession.Native, Is.EqualTo("Native driver on fake driver"));
49 | }
50 | }
51 |
52 | }
53 | }
--------------------------------------------------------------------------------
/src/Coypu.Tests/proxysettings.json:
--------------------------------------------------------------------------------
1 | {
2 | "Logging": {
3 | "LogLevel": {
4 | "Default": "Information"
5 | }
6 | },
7 | "AllowedHosts": "*",
8 | "ReverseProxy": {
9 | "Routes": {
10 | "route1" : {
11 | "ClusterId": "cluster1",
12 | "Match": {
13 | "Path": "{**catch-all}",
14 | "Hosts": ["www.example.com"]
15 | }
16 | },
17 | "route2" : {
18 | "ClusterId": "cluster2",
19 | "Match": {
20 | "Path": "{**catch-all}"
21 | }
22 | }
23 | },
24 | "Clusters": {
25 | "cluster1": {
26 | "Destinations": {
27 | "destination1": {
28 | "Address": "http://localhost:5000/"
29 | }
30 | }
31 | },
32 | "cluster2": {
33 | "Destinations": {
34 | "destination1": {
35 | "Address": "https://*/"
36 | }
37 | }
38 | }
39 | }
40 | }
41 | }
--------------------------------------------------------------------------------
/src/Coypu/Actions/AcceptModalDialog.cs:
--------------------------------------------------------------------------------
1 | namespace Coypu.Actions
2 | {
3 | internal class AcceptModalDialog : DriverAction
4 | {
5 | private readonly DriverScope driverScope;
6 |
7 | internal AcceptModalDialog(DriverScope driverScope, IDriver driver, Options options) : base(driver, driverScope, options)
8 | {
9 | this.driverScope = driverScope;
10 | }
11 |
12 | public override void Act()
13 | {
14 | Driver.AcceptModalDialog(driverScope);
15 | }
16 | }
17 | }
--------------------------------------------------------------------------------
/src/Coypu/Actions/BrowserAction.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Coypu.Queries;
3 |
4 | namespace Coypu.Actions
5 | {
6 | public abstract class BrowserAction : Query