Skip to content

Commit

Permalink
Fixes #92
Browse files Browse the repository at this point in the history
  • Loading branch information
raczeja committed Feb 5, 2019
1 parent 46a6f55 commit 72e2090
Show file tree
Hide file tree
Showing 15 changed files with 82 additions and 39 deletions.
39 changes: 36 additions & 3 deletions Objectivity.Test.Automation.Common/DriverContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public class DriverContext
/// <summary>
/// Gets or sets the Environment Browsers from App.config
/// </summary>
public BrowserType CrossBrowserEnvironment { get; set; }
public string CrossBrowserEnvironment { get; set; }

/// <summary>
/// Gets Sets Folder name for ScreenShot
Expand Down Expand Up @@ -523,7 +523,9 @@ public void Start()
case BrowserType.RemoteWebDriver:
var driverCapabilitiesConf = ConfigurationManager.GetSection("DriverCapabilities") as NameValueCollection;
NameValueCollection settings = ConfigurationManager.GetSection("environments/" + this.CrossBrowserEnvironment) as NameValueCollection;
switch (this.CrossBrowserEnvironment)
var browserType = this.GetBrowserTypeForRemoteDriver(settings);

switch (browserType)
{
case BrowserType.Firefox:
FirefoxOptions firefoxOptions = new FirefoxOptions();
Expand Down Expand Up @@ -555,7 +557,7 @@ public void Start()
break;
default:
throw new NotSupportedException(
string.Format(CultureInfo.CurrentCulture, "Driver {0} is not supported", BaseConfiguration.TestBrowser));
string.Format(CultureInfo.CurrentCulture, "Driver {0} is not supported", this.CrossBrowserEnvironment));
}

break;
Expand Down Expand Up @@ -870,5 +872,36 @@ private void SetRemoteDriverChromeOptions(NameValueCollection driverCapabilities
}
}
}

private BrowserType GetBrowserTypeForRemoteDriver(NameValueCollection settings)
{
if (BaseConfiguration.TestBrowserCapabilities != BrowserType.CloudProvider)
{
return BaseConfiguration.TestBrowserCapabilities;
}

BrowserType browserType = BrowserType.None;
bool supportedBrowser = false;
if (settings != null)
{
string browser = settings.GetValues("browser")?[0];
supportedBrowser = Enum.TryParse(browser, out browserType);
Logger.Info(CultureInfo.CurrentCulture, "supportedBrowser {0} : {1}", supportedBrowser, browserType);
}

if (!supportedBrowser)
{
if (this.CrossBrowserEnvironment.ToLower(CultureInfo.CurrentCulture).Contains(BrowserType.Android.ToString().ToLower(CultureInfo.CurrentCulture)))
{
browserType = BrowserType.Chrome;
}
else if (this.CrossBrowserEnvironment.ToLower(CultureInfo.CurrentCulture).Contains(BrowserType.Iphone.ToString().ToLower(CultureInfo.CurrentCulture)))
{
browserType = BrowserType.Safari;
}
}

return browserType;
}
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\packages\NUnit3TestAdapter.3.12.0\build\net35\NUnit3TestAdapter.props" Condition="Exists('..\packages\NUnit3TestAdapter.3.12.0\build\net35\NUnit3TestAdapter.props')" />
<Import Project="..\packages\NUnit.3.11.0\build\NUnit.props" Condition="Exists('..\packages\NUnit.3.11.0\build\NUnit.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
Expand Down Expand Up @@ -129,6 +130,7 @@
<Error Condition="!Exists('..\packages\Selenium.WebDriver.GeckoDriver.Win64.0.23.0\build\Selenium.WebDriver.GeckoDriver.Win64.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Selenium.WebDriver.GeckoDriver.Win64.0.23.0\build\Selenium.WebDriver.GeckoDriver.Win64.targets'))" />
<Error Condition="!Exists('..\packages\Selenium.WebDriver.IEDriver.3.141.0\build\Selenium.WebDriver.IEDriver.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Selenium.WebDriver.IEDriver.3.141.0\build\Selenium.WebDriver.IEDriver.targets'))" />
<Error Condition="!Exists('..\packages\Selenium.WebDriver.ChromeDriver.2.42.0.1\build\Selenium.WebDriver.ChromeDriver.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Selenium.WebDriver.ChromeDriver.2.42.0.1\build\Selenium.WebDriver.ChromeDriver.targets'))" />
<Error Condition="!Exists('..\packages\NUnit3TestAdapter.3.12.0\build\net35\NUnit3TestAdapter.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\NUnit3TestAdapter.3.12.0\build\net35\NUnit3TestAdapter.props'))" />
</Target>
<Import Project="..\packages\Selenium.WebDriver.GeckoDriver.Win64.0.23.0\build\Selenium.WebDriver.GeckoDriver.Win64.targets" Condition="Exists('..\packages\Selenium.WebDriver.GeckoDriver.Win64.0.23.0\build\Selenium.WebDriver.GeckoDriver.Win64.targets')" />
<Import Project="..\packages\Selenium.WebDriver.IEDriver.3.141.0\build\Selenium.WebDriver.IEDriver.targets" Condition="Exists('..\packages\Selenium.WebDriver.IEDriver.3.141.0\build\Selenium.WebDriver.IEDriver.targets')" />
Expand Down
1 change: 1 addition & 0 deletions Objectivity.Test.Automation.Tests.Angular/packages.config
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
<package id="NUnit.Extension.TeamCityEventListener" version="1.0.4" targetFramework="net452" />
<package id="NUnit.Extension.VSProjectLoader" version="3.8.0" targetFramework="net452" />
<package id="NUnit.Runners" version="3.9.0" targetFramework="net452" />
<package id="NUnit3TestAdapter" version="3.12.0" targetFramework="net452" />
<package id="Selenium.Support" version="3.141.0" targetFramework="net452" />
<package id="Selenium.WebDriver" version="3.141.0" targetFramework="net452" />
<package id="Selenium.WebDriver.ChromeDriver" version="2.42.0.1" targetFramework="net452" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@
<section name="ChromeArguments" type="System.Configuration.NameValueSectionHandler"/>
<section name="InternetExplorerPreferences" type="System.Configuration.NameValueSectionHandler"/>
<sectionGroup name="environments">
<section name="Chrome" type="System.Configuration.NameValueSectionHandler" />
<section name="Firefox" type="System.Configuration.NameValueSectionHandler" />
<section name="Safari" type="System.Configuration.NameValueSectionHandler" />
<section name="Edge" type="System.Configuration.NameValueSectionHandler" />
<section name="IE" type="System.Configuration.NameValueSectionHandler" />
<section name="ChromeWindows" type="System.Configuration.NameValueSectionHandler" />
<section name="FirefoxWindows" type="System.Configuration.NameValueSectionHandler" />
<section name="SafariMac" type="System.Configuration.NameValueSectionHandler" />
<section name="EdgeWindows" type="System.Configuration.NameValueSectionHandler" />
<section name="IEWindows" type="System.Configuration.NameValueSectionHandler" />
<section name="Android" type="System.Configuration.NameValueSectionHandler" />
<section name="Iphone" type="System.Configuration.NameValueSectionHandler" />
</sectionGroup>
Expand Down Expand Up @@ -98,34 +98,39 @@
<add key="extendedDebugging" value="true"/>
</DriverCapabilities>
<environments>
<Chrome>
<ChromeWindows>
<add key="browser" value="chrome" />
<add key="os" value="Windows"/>
<add key="os_version" value="10"/>
<add key="name" value="parallel_test" />
</Chrome>
<Firefox>
</ChromeWindows>
<FirefoxWindows>
<add key="browser" value="firefox" />
<add key="os" value="Windows"/>
<add key="os_version" value="10"/>
<add key="name" value="parallel_test" />
</Firefox>
<Safari>
</FirefoxWindows>
<SafariMac>
<add key="browser" value="safari" />
<add key="os" value="OS X"/>
<add key="os_version" value="High Sierra"/>
<add key="os_version" value="Mojave"/>
<add key="name" value="parallel_test" />
<!-->testingbot Settings/-->
<add key="platform" value="HIGH-SIERRA" />
<add key="version" value="11" />
</Safari>
<Edge>
<!-->saucelabs Settings/-->
<add key="platform" value="macOS 10.14" />
<add key="version" value="12.0" />
</SafariMac>
<EdgeWindows>
<add key="browser" value="edge" />
<add key="os" value="Windows"/>
<add key="os_version" value="10"/>
<add key="name" value="parallel_test" />
</Edge>
<IE>
</EdgeWindows>
<IEWindows>
<add key="browser" value="IE" />
<add key="os" value="Windows"/>
<add key="os_version" value="10"/>
<add key="name" value="parallel_test" />
</IE>
</IEWindows>
<Android>
<add key="device" value="Samsung Galaxy S8"/>
<add key="realMobile" value="true"/>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\packages\NUnit3TestAdapter.3.12.0\build\net35\NUnit3TestAdapter.props" Condition="Exists('..\packages\NUnit3TestAdapter.3.12.0\build\net35\NUnit3TestAdapter.props')" />
<Import Project="..\packages\NUnit.3.11.0\build\NUnit.props" Condition="Exists('..\packages\NUnit.3.11.0\build\NUnit.props')" />
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
Expand Down Expand Up @@ -123,6 +124,7 @@
</PropertyGroup>
<Error Condition="!Exists('$(SolutionDir)\.nuget\NuGet.targets')" Text="$([System.String]::Format('$(ErrorText)', '$(SolutionDir)\.nuget\NuGet.targets'))" />
<Error Condition="!Exists('..\packages\NUnit.3.11.0\build\NUnit.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\NUnit.3.11.0\build\NUnit.props'))" />
<Error Condition="!Exists('..\packages\NUnit3TestAdapter.3.12.0\build\net35\NUnit3TestAdapter.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\NUnit3TestAdapter.3.12.0\build\net35\NUnit3TestAdapter.props'))" />
</Target>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,9 @@ private readonly DriverContext

public ProjectTestBase(string environment)
{
BrowserType browserType;
bool supportedBrowser = Enum.TryParse(environment, out browserType);
Logger.Info(CultureInfo.CurrentCulture, "supportedBrowser {0} : {1}", supportedBrowser, browserType);
Logger.Info(CultureInfo.CurrentCulture, "environment {0}", environment);

if (supportedBrowser)
{
this.DriverContext.CrossBrowserEnvironment = browserType;
}
this.DriverContext.CrossBrowserEnvironment = environment;
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@ namespace Objectivity.Test.Automation.Tests.CloudProviderCrossBrowser.Tests
using global::NUnit.Framework;
using PageObjects.PageObjects.TheInternet;

[TestFixture("Chrome")]
[TestFixture("ChromeWindows")]
[TestFixture("Android")]
[TestFixture("Iphone")]
[TestFixture("Firefox")]
[TestFixture("Safari")]
[TestFixture("Edge")]
[TestFixture("IE")]
[TestFixture("FirefoxWindows")]
[TestFixture("SafariMac")]
[TestFixture("EdgeWindows")]
[TestFixture("IEWindows")]
[Parallelizable(ParallelScope.Fixtures)]
public class HerokuappTestsNUnit : ProjectTestBase
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
<package id="NUnit.Extension.TeamCityEventListener" version="1.0.4" targetFramework="net45" />
<package id="NUnit.Extension.VSProjectLoader" version="3.8.0" targetFramework="net45" />
<package id="NUnit.Runners" version="3.9.0" targetFramework="net45" />
<package id="NUnit3TestAdapter" version="3.12.0" targetFramework="net45" />
<package id="Selenium.WebDriver" version="3.141.0" targetFramework="net45" />
<package id="StyleCop.Analyzers" version="1.0.2" targetFramework="net45" developmentDependency="true" />
</packages>
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\packages\NUnit3TestAdapter.3.12.0\build\net35\NUnit3TestAdapter.props" Condition="Exists('..\packages\NUnit3TestAdapter.3.12.0\build\net35\NUnit3TestAdapter.props')" />
<Import Project="..\packages\NUnit.3.11.0\build\NUnit.props" Condition="Exists('..\packages\NUnit.3.11.0\build\NUnit.props')" />
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
Expand Down Expand Up @@ -127,6 +128,7 @@
<Error Condition="!Exists('..\packages\Selenium.WebDriver.IEDriver.3.141.0\build\Selenium.WebDriver.IEDriver.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Selenium.WebDriver.IEDriver.3.141.0\build\Selenium.WebDriver.IEDriver.targets'))" />
<Error Condition="!Exists('..\packages\Selenium.WebDriver.IEDriver.3.141.0\build\Selenium.WebDriver.IEDriver.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Selenium.WebDriver.IEDriver.3.141.0\build\Selenium.WebDriver.IEDriver.targets'))" />
<Error Condition="!Exists('..\packages\Selenium.WebDriver.ChromeDriver.2.42.0.1\build\Selenium.WebDriver.ChromeDriver.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Selenium.WebDriver.ChromeDriver.2.42.0.1\build\Selenium.WebDriver.ChromeDriver.targets'))" />
<Error Condition="!Exists('..\packages\NUnit3TestAdapter.3.12.0\build\net35\NUnit3TestAdapter.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\NUnit3TestAdapter.3.12.0\build\net35\NUnit3TestAdapter.props'))" />
</Target>
<Import Project="..\packages\Selenium.WebDriver.GeckoDriver.Win64.0.22.0\build\Selenium.WebDriver.GeckoDriver.Win64.targets" Condition="Exists('..\packages\Selenium.WebDriver.GeckoDriver.Win64.0.22.0\build\Selenium.WebDriver.GeckoDriver.Win64.targets')" />
<Import Project="..\packages\Selenium.WebDriver.IEDriver.3.141.0\build\Selenium.WebDriver.IEDriver.targets" Condition="Exists('..\packages\Selenium.WebDriver.IEDriver.3.141.0\build\Selenium.WebDriver.IEDriver.targets')" />
Expand Down
1 change: 1 addition & 0 deletions Objectivity.Test.Automation.Tests.Features/packages.config
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
<package id="NUnit.Extension.TeamCityEventListener" version="1.0.4" targetFramework="net45" />
<package id="NUnit.Extension.VSProjectLoader" version="3.8.0" targetFramework="net45" />
<package id="NUnit.Runners" version="3.9.0" targetFramework="net45" />
<package id="NUnit3TestAdapter" version="3.12.0" targetFramework="net45" />
<package id="Selenium.WebDriver.ChromeDriver" version="2.42.0.1" targetFramework="net45" />
<package id="Selenium.WebDriver.GeckoDriver.Win64" version="0.23.0" targetFramework="net45" />
<package id="Selenium.WebDriver.IEDriver" version="3.141.0" targetFramework="net45" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\packages\NUnit3TestAdapter.3.12.0\build\net35\NUnit3TestAdapter.props" Condition="Exists('..\packages\NUnit3TestAdapter.3.12.0\build\net35\NUnit3TestAdapter.props')" />
<Import Project="..\packages\NUnit.3.11.0\build\NUnit.props" Condition="Exists('..\packages\NUnit.3.11.0\build\NUnit.props')" />
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
Expand Down Expand Up @@ -181,6 +182,7 @@
<Error Condition="!Exists('..\packages\Selenium.WebDriver.GeckoDriver.Win64.0.23.0\build\Selenium.WebDriver.GeckoDriver.Win64.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Selenium.WebDriver.GeckoDriver.Win64.0.23.0\build\Selenium.WebDriver.GeckoDriver.Win64.targets'))" />
<Error Condition="!Exists('..\packages\Selenium.WebDriver.IEDriver.3.141.0\build\Selenium.WebDriver.IEDriver.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Selenium.WebDriver.IEDriver.3.141.0\build\Selenium.WebDriver.IEDriver.targets'))" />
<Error Condition="!Exists('..\packages\Selenium.WebDriver.ChromeDriver.2.42.0.1\build\Selenium.WebDriver.ChromeDriver.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Selenium.WebDriver.ChromeDriver.2.42.0.1\build\Selenium.WebDriver.ChromeDriver.targets'))" />
<Error Condition="!Exists('..\packages\NUnit3TestAdapter.3.12.0\build\net35\NUnit3TestAdapter.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\NUnit3TestAdapter.3.12.0\build\net35\NUnit3TestAdapter.props'))" />
</Target>
<Import Project="..\packages\Selenium.WebDriver.GeckoDriver.Win64.0.23.0\build\Selenium.WebDriver.GeckoDriver.Win64.targets" Condition="Exists('..\packages\Selenium.WebDriver.GeckoDriver.Win64.0.23.0\build\Selenium.WebDriver.GeckoDriver.Win64.targets')" />
<Import Project="..\packages\Selenium.WebDriver.IEDriver.3.141.0\build\Selenium.WebDriver.IEDriver.targets" Condition="Exists('..\packages\Selenium.WebDriver.IEDriver.3.141.0\build\Selenium.WebDriver.IEDriver.targets')" />
Expand Down
5 changes: 0 additions & 5 deletions Objectivity.Test.Automation.Tests.NUnit/ProjectTestBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,6 @@ protected DriverContext DriverContext
[OneTimeSetUp]
public void BeforeClass()
{
if (BaseConfiguration.TestBrowser == BrowserType.RemoteWebDriver)
{
this.DriverContext.CrossBrowserEnvironment = BaseConfiguration.TestBrowserCapabilities;
}

this.DriverContext.CurrentDirectory = TestContext.CurrentContext.TestDirectory;
this.DriverContext.Start();
}
Expand Down
1 change: 1 addition & 0 deletions Objectivity.Test.Automation.Tests.NUnit/packages.config
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
<package id="NUnit.Extension.TeamCityEventListener" version="1.0.4" targetFramework="net45" />
<package id="NUnit.Extension.VSProjectLoader" version="3.8.0" targetFramework="net45" />
<package id="NUnit.Runners" version="3.9.0" targetFramework="net45" />
<package id="NUnit3TestAdapter" version="3.12.0" targetFramework="net45" />
<package id="Selenium.WebDriver" version="3.141.0" targetFramework="net45" />
<package id="Selenium.WebDriver.ChromeDriver" version="2.42.0.1" targetFramework="net45" />
<package id="Selenium.WebDriver.GeckoDriver.Win64" version="0.23.0" targetFramework="net45" />
Expand Down
Loading

0 comments on commit 72e2090

Please sign in to comment.