Skip to content

Commit

Permalink
Merge pull request #6 from tnypxl/move-to-single-project
Browse files Browse the repository at this point in the history
Move to single project
  • Loading branch information
tnypxl authored Mar 25, 2020
2 parents 2ce9ad8 + 7fcad41 commit ba899cb
Show file tree
Hide file tree
Showing 23 changed files with 1,078 additions and 14 deletions.
11 changes: 11 additions & 0 deletions Basin.DuckDuckGoExample/DuckDuckGo.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"SiteConfig": {
"Name": "DuckDuckGo",
"Url": "https://duckduckgo.com"
},

"DriverConfig": {
"Browser": "Chrome",
"Timeout": 20
}
}
4 changes: 2 additions & 2 deletions Basin.DuckDuckGoExample/Shared/Sidebar.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public class Sidebar : PageBase, IPage<SidebarMap>

public Sidebar SlideOpen()
{
Map.HamburgerButton.Click();
Map.HamburgerMenu.Click();
Wait.Until(Map.Container.IsDisplaying);

return this;
Expand Down Expand Up @@ -47,7 +47,7 @@ public class SidebarMap : PageMapBase, IPageMap

public Element Container => Locate(By.CssSelector(SidebarContainer));

public Element HamburgerButton => Locate(By.CssSelector(".header--aside .header__button--menu.js-side-menu-open"));
public Element HamburgerMenu => Locate(By.CssSelector(".header--aside .header__button--menu.js-side-menu-open"));

public Element Themes => Locate(LinkBy("https://duckduckgo.com/settings#theme"));

Expand Down
18 changes: 6 additions & 12 deletions Basin.sln
Original file line number Diff line number Diff line change
@@ -1,27 +1,17 @@

Microsoft Visual Studio Solution File, Format Version 12.00
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Basin.Selenium", "Basin.Selenium\Basin.Selenium.csproj", "{A4D9B093-3A16-445E-896B-DDC77F7E3E65}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Basin.Screens", "Basin.Screens\Basin.Screens.csproj", "{891BA36B-9EEE-4464-8EB3-526D7A42EBAF}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Basin.Utils", "Basin.Utils\Basin.Utils.csproj", "{F6E80C20-6D67-42B2-8C3F-0E58FDE47EB5}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Basin.DuckDuckGoExample", "Basin.DuckDuckGoExample\Basin.DuckDuckGoExample.csproj", "{C4C5DCDA-1DBB-49FA-A766-B7A82D8EDE51}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Basin", "Basin\Basin.csproj", "{A69E54D5-45F3-4F53-A6B5-85BB1F89C73D}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{A4D9B093-3A16-445E-896B-DDC77F7E3E65}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A4D9B093-3A16-445E-896B-DDC77F7E3E65}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A4D9B093-3A16-445E-896B-DDC77F7E3E65}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A4D9B093-3A16-445E-896B-DDC77F7E3E65}.Release|Any CPU.Build.0 = Release|Any CPU
{891BA36B-9EEE-4464-8EB3-526D7A42EBAF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{891BA36B-9EEE-4464-8EB3-526D7A42EBAF}.Debug|Any CPU.Build.0 = Debug|Any CPU
{891BA36B-9EEE-4464-8EB3-526D7A42EBAF}.Release|Any CPU.ActiveCfg = Release|Any CPU
{891BA36B-9EEE-4464-8EB3-526D7A42EBAF}.Release|Any CPU.Build.0 = Release|Any CPU
{F6E80C20-6D67-42B2-8C3F-0E58FDE47EB5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F6E80C20-6D67-42B2-8C3F-0E58FDE47EB5}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F6E80C20-6D67-42B2-8C3F-0E58FDE47EB5}.Release|Any CPU.ActiveCfg = Release|Any CPU
Expand All @@ -30,5 +20,9 @@ Global
{C4C5DCDA-1DBB-49FA-A766-B7A82D8EDE51}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C4C5DCDA-1DBB-49FA-A766-B7A82D8EDE51}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C4C5DCDA-1DBB-49FA-A766-B7A82D8EDE51}.Release|Any CPU.Build.0 = Release|Any CPU
{A69E54D5-45F3-4F53-A6B5-85BB1F89C73D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A69E54D5-45F3-4F53-A6B5-85BB1F89C73D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A69E54D5-45F3-4F53-A6B5-85BB1F89C73D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A69E54D5-45F3-4F53-A6B5-85BB1F89C73D}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
EndGlobal
73 changes: 73 additions & 0 deletions Basin/Basin.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
// <auto-generated />

using System.Collections.Generic;
using System.Globalization;
using Basin.Config.Interfaces;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;

namespace Basin
{
public partial class Basin
{
[JsonProperty("Site")] public SiteConfig Site { get; set; }

[JsonProperty("Driver")] public DriverConfig Driver { get; set; }

[JsonProperty("Logins")] public List<LoginConfig> Logins { get; set; }
}

public class DriverConfig : IDriverConfig
{
[JsonProperty("Timeout")] public int Timeout { get; set; }

[JsonProperty("Browser")] public string Browser { get; set; }
}

public class LoginConfig : ILoginConfig
{
[JsonProperty("Role")] public string Role { get; set; }

[JsonProperty("Username")] public string Username { get; set; }

[JsonProperty("Password")] public string Password { get; set; }

[JsonProperty("Token")] public string Token { get; set; }
}

public class SiteConfig : ISiteConfig
{
[JsonProperty("Name")] public string Name { get; set; }

[JsonProperty("Url")] public string Url { get; set; }
}

public partial class Basin
{
public static Basin FromJson(string json)
{
return JsonConvert.DeserializeObject<Basin>(json, Converter.Settings);
}
}

public static class Serialize
{
public static string ToJson(this Basin self)
{
return JsonConvert.SerializeObject(self, Converter.Settings);
}
}

internal static class Converter
{
public static readonly JsonSerializerSettings Settings = new JsonSerializerSettings
{
MetadataPropertyHandling = MetadataPropertyHandling.Ignore,
DateParseHandling = DateParseHandling.None,
Converters =
{
new IsoDateTimeConverter {DateTimeStyles = DateTimeStyles.AssumeUniversal}
}
};
}
}
36 changes: 36 additions & 0 deletions Basin/Basin.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<PackageId>BasinFramework</PackageId>
<PackageVersion>0.0.1</PackageVersion>
<Title>Arik Jones</Title>
<Authors>BasinFramework</Authors>
<TargetFrameworks>net472;netcoreapp2.1</TargetFrameworks>
<LangVersion>8</LangVersion>
<Copyright>Arik Jones</Copyright>
<PackageProjectUrl>https://github.com/tnypxl/BasinFrameworkDotNetCore</PackageProjectUrl>
<PackageLicenseUrl>https://raw.githubusercontent.com/tnypxl/BasinFrameworkDotNetCore/master/LICENSE</PackageLicenseUrl>
<RepositoryUrl>https://github.com/tnypxl/BasinFrameworkDotNetCore</RepositoryUrl>
<RepositoryType>GitHub</RepositoryType>
<PackageTags>selenium, browser, automation, framework</PackageTags>
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
<PackageReference Include="Selenium.WebDriver" Version="3.141.0" />
<PackageReference Include="Selenium.WebDriver.ChromeDriver" Version="80.0.3987.10600" />
<PackageReference Include="Selenium.WebDriver.GeckoDriver" Version="0.26.0" />
<PackageReference Include="Selenium.WebDriver.IEDriver" Version="3.150.1" />
</ItemGroup>

<ItemGroup>
<Folder Include="Config" />
</ItemGroup>

<ItemGroup>
<Reference Include="Microsoft.CSharp" Condition="'$(TargetFramework)' == 'net472'" />
<Reference Include="Mono.CSharp" Condition="'$(TargetFramework)' == 'net472'" />
</ItemGroup>

</Project>
12 changes: 12 additions & 0 deletions Basin/Config/Interfaces/IDatabaseConfig.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using System;

namespace Basin.Config.Interfaces
{
public interface IDatabaseConfig
{
Uri Host { get; set; }
string Port { get; set; }
string Username { get; set; }
string Password { get; set; }
}
}
8 changes: 8 additions & 0 deletions Basin/Config/Interfaces/IDriverConfig.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
namespace Basin.Config.Interfaces
{
public interface IDriverConfig
{
int Timeout { get; set; }
string Browser { get; set; }
}
}
10 changes: 10 additions & 0 deletions Basin/Config/Interfaces/ILoginConfig.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
namespace Basin.Config.Interfaces
{
public interface ILoginConfig
{
string Role { get; set; }
string Username { get; set; }
string Password { get; set; }
string Token { get; set; }
}
}
8 changes: 8 additions & 0 deletions Basin/Config/Interfaces/ISiteConfig.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
namespace Basin.Config.Interfaces
{
public interface ISiteConfig
{
string Name { get; set; }
string Url { get; set; }
}
}
44 changes: 44 additions & 0 deletions Basin/Screens/Interfaces/IScreen.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
using Basin.Selenium;

namespace Basin.Screens.Interfaces
{
/// <summary>
/// Interface for defining page/screen object classes.
/// </summary>
/// <typeparam name="TScreenMap"></typeparam>
public interface IScreen<out TScreenMap>
{
/// <summary>
/// Implements accessor for an IScreenMap class object.
/// </summary>
TScreenMap Map { get; }
}


/// <inheritdoc cref="IScreen{TScreenMap}" />
/// <typeparam name="TPageMap"></typeparam>
public interface IPage<out TPageMap> : IScreen<TPageMap>
{
}

/// <inheritdoc cref="IScreen{TScreenMap}" />
/// <typeparam name="TScreenComponentMap"></typeparam>
public interface IScreenComponent<out TScreenComponentMap> : IScreen<TScreenComponentMap>
{
}

/// <inheritdoc cref="IScreen{TScreenMap}" />
/// <typeparam name="TPageComponentMap"></typeparam>
public interface IPageComponent<out TPageComponentMap> : IScreen<TPageComponentMap>
{
}

//
public interface IPageBase
{
/// <summary>
/// Interface for implementing methods from Basin.Selenium.Driver.
/// </summary>
Wait Wait { get; }
}
}
38 changes: 38 additions & 0 deletions Basin/Screens/Interfaces/IScreenMap.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
using Basin.Selenium;
using OpenQA.Selenium;

namespace Basin.Screens.Interfaces
{
/// <summary>
/// Interface for implementing methods from Basin.Selenium.Driver.
/// </summary>
public interface IScreenMapBase
{
Element Locate(By by);

Element Locate(string css);

Elements LocateAll(By by);
}

/// <summary>
/// Interface for page/screen map classes.
/// </summary>
public interface IScreenMap
{
/// <summary>
/// Adds a common method for defining the root/containing element in a map class.
/// </summary>
Element Container { get; }
}

/// <inheritdoc cref="IScreenMap" />
public interface IPageMap : IScreenMap
{
}

/// <inheritdoc cref="IScreenMapBase" />
public interface IPageMapBase : IScreenMapBase
{
}
}
20 changes: 20 additions & 0 deletions Basin/Selenium/Browsers/Chrome.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using OpenQA.Selenium;
using OpenQA.Selenium.Chrome;

namespace Basin.Selenium.Browsers
{
internal class Chrome
{
public readonly IWebDriver Current;

public Chrome(ChromeOptions opts = null)
{
var options = opts ?? new ChromeOptions();
var service = ChromeDriverService.CreateDefaultService();

service.HideCommandPromptWindow = true;

Current = new ChromeDriver(service, options);
}
}
}
20 changes: 20 additions & 0 deletions Basin/Selenium/Browsers/Firefox.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using OpenQA.Selenium;
using OpenQA.Selenium.Firefox;

namespace Basin.Selenium.Browsers
{
public class Firefox
{
public readonly IWebDriver Current;

public Firefox(FirefoxOptions opts = null)
{
var options = opts ?? new FirefoxOptions();
var service = FirefoxDriverService.CreateDefaultService();

service.HideCommandPromptWindow = true;

Current = new FirefoxDriver(service, options);
}
}
}
20 changes: 20 additions & 0 deletions Basin/Selenium/Browsers/InternetExplorer.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using OpenQA.Selenium;
using OpenQA.Selenium.IE;

namespace Basin.Selenium.Browsers
{
public class InternetExplorer
{
public readonly IWebDriver Current;

public InternetExplorer(InternetExplorerOptions opts = null)
{
var options = opts ?? new InternetExplorerOptions();
var service = InternetExplorerDriverService.CreateDefaultService();

service.HideCommandPromptWindow = true;

Current = new InternetExplorerDriver(service, options);
}
}
}
Loading

0 comments on commit ba899cb

Please sign in to comment.