Skip to content
This repository has been archived by the owner on Apr 30, 2022. It is now read-only.

Commit

Permalink
Merge pull request #858 from Magenic/feature/W3CConfig
Browse files Browse the repository at this point in the history
Feature/W3C config
  • Loading branch information
TroyWalshProf authored Nov 19, 2021
2 parents 47d4714 + bb51061 commit 278359b
Show file tree
Hide file tree
Showing 18 changed files with 312 additions and 162 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ jobs:
- id: builder
uses: ./.github/workflows/buildtest-action
with:
bt-param: 'Framework/AppiumUnitTests/AppiumUnitTests.csproj --settings Framework/SauceLabs.RunSettings --filter FullyQualifiedName!~AppiumWinAppUnitTests --logger trx --results-directory "${{github.workspace}}/artifactTests/appium/testResults/" /p:CoverletOutput="${{github.workspace}}/artifactTests/appium/" /p:CollectCoverage=true /p:CoverletOutputFormat=opencover -- ''TestRunParameters.Parameter(name=\"AppiumCapsMaqs:accessKey\",value=\"${{ secrets.SAUCE }}\")'''
bt-param: 'Framework/AppiumUnitTests/AppiumUnitTests.csproj --settings Framework/SauceLabs.RunSettings --filter FullyQualifiedName!~AppiumWinAppUnitTests --logger trx --results-directory "${{github.workspace}}/artifactTests/appium/testResults/" /p:CoverletOutput="${{github.workspace}}/artifactTests/appium/" /p:CollectCoverage=true /p:CoverletOutputFormat=opencover -- ''TestRunParameters.Parameter(name=\"AppiumCapsMaqs:sauce:options:accessKey\",value=\"${{ secrets.SAUCE }}\")'''
- uses: actions/upload-artifact@v2
if: always()
name: "Upload test artifact"
Expand Down Expand Up @@ -420,7 +420,7 @@ jobs:
- id: builder
uses: ./.github/workflows/buildtest-action
with:
bt-param: 'Framework/SeleniumUnitTests/SeleniumUnitTests.csproj --settings Framework/SauceLabs.RunSettings --filter "(FullyQualifiedName!~SeleniumNUnitTest)&(FullyQualifiedName!~Proxy)&(FullyQualifiedName!~SeleniumConfigTests)&(FullyQualifiedName!~SeleniumPageObjectUnitTest)&(FullyQualifiedName!~LazyElementUnitTests)&(FullyQualifiedName!~SeleniumUnitTests.SeleniumUnitTest)&(FullyQualifiedName!~SeleniumWebElementTest)&(FullyQualifiedName!~SeleniumUtilsTest)" --logger trx --results-directory "${{github.workspace}}/artifactTests/selengen/testResults/" /p:CoverletOutput="${{github.workspace}}/artifactTests/selengen/" /p:CollectCoverage=true /p:CoverletOutputFormat=opencover -- ''TestRunParameters.Parameter(name=\"RemoteSeleniumCapsMaqs:accessKey\",value=\"${{ secrets.SAUCE }}\")'' ''TestRunParameters.Parameter(name=\"RemoteSeleniumCapsMaqs:RunOnSauceLabs\",value=\"YES\")'''
bt-param: 'Framework/SeleniumUnitTests/SeleniumUnitTests.csproj --settings Framework/SauceLabs.RunSettings --filter "(FullyQualifiedName!~SeleniumNUnitTest)&(FullyQualifiedName!~Proxy)&(FullyQualifiedName!~SeleniumConfigTests)&(FullyQualifiedName!~SeleniumPageObjectUnitTest)&(FullyQualifiedName!~LazyElementUnitTests)&(FullyQualifiedName!~SeleniumUnitTests.SeleniumUnitTest)&(FullyQualifiedName!~SeleniumWebElementTest)&(FullyQualifiedName!~SeleniumUtilsTest)" --logger trx --results-directory "${{github.workspace}}/artifactTests/selengen/testResults/" /p:CoverletOutput="${{github.workspace}}/artifactTests/selengen/" /p:CollectCoverage=true /p:CoverletOutputFormat=opencover -- ''TestRunParameters.Parameter(name=\"RemoteSeleniumCapsMaqs:sauce:options:accessKey\",value=\"${{ secrets.SAUCE }}\")'' ''TestRunParameters.Parameter(name=\"SeleniumMaqs:RunOnSauceLabs\",value=\"YES\")'''
- uses: actions/upload-artifact@v2
if: always()
name: "Upload test artifact"
Expand Down
9 changes: 5 additions & 4 deletions Framework/AppiumUnitTests/App.config
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,10 @@
<add key="SavePagesourceOnFail" value="YES" />
</AppiumMaqs>
<AppiumCapsMaqs>
<!--<add key="sauce:options" value="{username: 'magenicMAQSService', accessKey: 'NEVER_ADD', appiumVersion: '1.20.2', orientation: 'portrait' }" />-->
<add key="username" value="magenicMAQSService" />
<add key="accessKey" value="NEVER_ADD'" />
<add key="appiumVersion" value="1.20.2" />
<add key="sauce:options">
<add key="username" value="magenicMAQSService" />
<add key="accessKey" value="NEVER_ENTER_THIS_VALUE" />
<add key="appiumVersion" value="1.20.2" />
</add>
</AppiumCapsMaqs>
</configuration>
12 changes: 0 additions & 12 deletions Framework/AppiumUnitTests/AppiumConfigTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
using Magenic.Maqs.BaseAppiumTest;
using Magenic.Maqs.Utilities.Helper;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Newtonsoft.Json;
using OpenQA.Selenium.Appium;
using OpenQA.Selenium.Support.UI;
using System;
Expand All @@ -20,17 +19,6 @@ namespace AppiumUnitTests
[TestClass]
public class AppiumConfigTests
{
/// <summary>
/// Update configuration with context overrides
/// </summary>
/// <param name="testContext">The test context</param>
[AssemblyInitialize]
public static void Initialize(TestContext testContext)
{
Config.UpdateWithVSTestContext(testContext);
Config.AddTestSettingValue("sauce:options", JsonConvert.SerializeObject(AppiumConfig.GetCapabilitiesAsStrings()), ConfigSection.AppiumCapsMaqs);
}

/// <summary>
/// Test for getting Mobile Device OS
/// </summary>
Expand Down
12 changes: 5 additions & 7 deletions Framework/AppiumUnitTests/AppiumIosUnitTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,15 +83,13 @@ protected override AppiumDriver GetMobileDevice()
PlatformName = "iOS",
PlatformVersion = "15.0",
BrowserName = "Safari"
};
};

var sauceCreds = Config.GetValueForSection(ConfigSection.AppiumCapsMaqs, "sauce:options");

// Use Appium 1.22 for running iOS tests
sauceCreds = sauceCreds.Replace("1.20.2", "1.22.0");
var sauceOptions = AppiumConfig.GetCapabilitiesAsObjects();

options.AddAdditionalAppiumOption("sauce:options", JsonConvert.DeserializeObject<Dictionary<string, string>>(sauceCreds));
options.AddAdditionalAppiumOption("deviceOrientation", "portrait");
// Use Appium 1.22 for running iOS tests
(sauceOptions["sauce:options"] as Dictionary<string, object>)["appiumVersion"] = "1.22.0";
options.SetMobileOptions(sauceOptions);

return AppiumDriverFactory.GetIOSDriver(AppiumConfig.GetMobileHubUrl(), options, AppiumConfig.GetMobileCommandTimeout());
}
Expand Down
16 changes: 16 additions & 0 deletions Framework/AppiumUnitTests/AppiumUtilitiesTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,22 @@ public void CreateAppiumTestObjectWithDriver()
Assert.AreEqual(this.Log, newObject.Log);
}

/// <summary>
/// Verify mobile options work when null capablites
/// </summary>
[TestMethod]
public void SetMobileOptionsWithNullDictionary()
{
var options = AppiumDriverFactory.GetDefaultMobileOptions();
var beforeOptions = options.ToDictionary();

// Add null
options.SetMobileOptions(null);

// Makes sure we didn't add or remove options
Assert.AreEqual(beforeOptions.Count, options.ToDictionary().Count);
}

/// <summary>
/// Verify a bad create fails in the right way
/// </summary>
Expand Down
11 changes: 1 addition & 10 deletions Framework/BaseAppiumTest/AppiumConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -155,22 +155,13 @@ public static bool GetSoftAssertScreenshot()
return Config.GetValueForSection(ConfigSection.AppiumMaqs, "SoftAssertScreenshot").Equals("Yes", StringComparison.CurrentCultureIgnoreCase);
}

/// <summary>
/// Get the capabilities as a dictionary
/// </summary>
/// <returns>Dictionary of capabilities</returns>
public static Dictionary<string, string> GetCapabilitiesAsStrings()
{
return Config.GetSectionDictionary(ConfigSection.AppiumCapsMaqs);
}

/// <summary>
/// Get the capabilities as a dictionary
/// </summary>
/// <returns>Dictionary of capabilities</returns>
public static Dictionary<string, object> GetCapabilitiesAsObjects()
{
return GetCapabilitiesAsStrings().ToDictionary(pair => pair.Key, pair => (object)pair.Value);
return Config.GetMultilevelDictionary(ConfigSection.AppiumCapsMaqs);
}

/// <summary>
Expand Down
6 changes: 2 additions & 4 deletions Framework/BaseAppiumTest/AppiumDriverFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -220,11 +220,11 @@ public static AppiumOptions GetDefaultMobileOptions()
/// <param name="appiumOptions">The driver options to make this an extension method</param>
/// <param name="capabilities">The mobile driver capabilities</param>
/// <returns>The altered <see cref="DriverOptions"/> driver options</returns>
private static AppiumOptions SetMobileOptions(this AppiumOptions appiumOptions, Dictionary<string, object> capabilities)
public static void SetMobileOptions(this AppiumOptions appiumOptions, Dictionary<string, object> capabilities)
{
if (capabilities == null)
{
return appiumOptions;
return;
}

foreach (KeyValuePair<string, object> keyValue in capabilities)
Expand All @@ -244,8 +244,6 @@ private static AppiumOptions SetMobileOptions(this AppiumOptions appiumOptions,
}
}
}

return appiumOptions;
}
}
}
12 changes: 1 addition & 11 deletions Framework/BaseSeleniumTest/SeleniumConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using WebDriverManager.Helpers;

Expand Down Expand Up @@ -246,22 +245,13 @@ public static string GetImageFormat()
return Config.GetValueForSection(SELENIUMSECTION, "ImageFormat", "PNG");
}

/// <summary>
/// Get the remote capabilities as a dictionary
/// </summary>
/// <returns>Dictionary of remote capabilities</returns>
public static Dictionary<string, string> GetRemoteCapabilitiesAsStrings()
{
return Config.GetSectionDictionary(ConfigSection.RemoteSeleniumCapsMaqs);
}

/// <summary>
/// Get the remote capabilities as a dictionary
/// </summary>
/// <returns>Dictionary of remote capabilities</returns>
public static Dictionary<string, object> GetRemoteCapabilitiesAsObjects()
{
return GetRemoteCapabilitiesAsStrings().ToDictionary(pair => pair.Key, pair => (object)pair.Value);
return Config.GetMultilevelDictionary(ConfigSection.RemoteSeleniumCapsMaqs);
}

/// <summary>
Expand Down
10 changes: 4 additions & 6 deletions Framework/SauceLabs.RunSettings
Original file line number Diff line number Diff line change
Expand Up @@ -20,22 +20,20 @@
<Parameter name="DatabasEMaqs:SectionOverride" value="SAMPLEDatabase" />
<Parameter name="EmailMaqS:SectionOverride" value="SAMPLEEmail" />
<Parameter name="SeleniumMAqs:SectionOverride" value="SAMPLESel" />
<Parameter name="RemoteseleniumCapsMaqs:SectionOverride" value="SAMPLESelCap" />
<Parameter name="WebServiceMaqs:SectionOverride" value="SAMPLEWeb" />
<Parameter name="magenicMaqs:SectionAdd" value="SAMPLEGenz" />
<Parameter name="appiummaqs:SectionAdd" value="SAMPLEAppz" />
<Parameter name="appiumCapsMaqs:SectionAdd" value="SAMPLEAppCapz" />
<Parameter name="Databasemaqs:SectionAdd" value="SAMPLEDatabasez" />
<Parameter name="Emailmaqs:SectionAdd" value="SAMPLEEmailz" />
<Parameter name="SeleniumMaqs:SectionAdd" value="SAMPLESelz" />
<Parameter name="RemoteseleniumCapsMaqs:SectionAdd" value="SAMPLESelCapz" />
<Parameter name="webServiceMaqs:SectionAdd" value="SAMPLEWebz" />
<Parameter name="SeleniumMaqs:Browser" value="Remote" />
<Parameter name="AppiumCapsMaqs:username" value="magenicMAQSService" />
<Parameter name="RemoteSeleniumCapsMaqs:username" value="magenicMAQSService" />
<Parameter name="RemoteSeleniumCapsMaqs:accessKey" value="OVERRIDE_ME_ON_COMMANDLINE" />
<Parameter name="AppiumCapsMaqs:accessKey" value="OVERRIDE_ME_ON_COMMANDLINE" />
<Parameter name="RemoteSeleniumCapsMaqs:RunOnSauceLabs" value="YES" />
<Parameter name="RemoteSeleniumCapsMaqs:sauce:options:username" value="magenicMAQSService" />
<Parameter name="RemoteSeleniumCapsMaqs:sauce:options:accessKey" value="OVERRIDE_ME_ON_COMMANDLINE" />
<Parameter name="AppiumCapsMaqs:sauce:options:accessKey" value="OVERRIDE_ME_ON_COMMANDLINE" />
<Parameter name="SeleniumMaqs:RunOnSauceLabs" value="YES" />
</TestRunParameters>
<DataCollectionRunSettings>
<DataCollectors>
Expand Down
110 changes: 55 additions & 55 deletions Framework/SeleniumUnitTests/App.config
Original file line number Diff line number Diff line change
@@ -1,81 +1,81 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<section name="MagenicMaqs" type="System.Configuration.NameValueSectionHandler" />
<section name="SeleniumMaqs" type="System.Configuration.NameValueSectionHandler" />
<section name="RemoteSeleniumCapsMaqs" type="System.Configuration.NameValueSectionHandler" />
</configSections>
<MagenicMaqs>
<!--For configuration override tests-->
<add key="OverrideTest" value="not overridden" />
<add key="OverrideNUnitTest" value="not overridden" />
<configSections>
<section name="MagenicMaqs" type="System.Configuration.NameValueSectionHandler" />
<section name="SeleniumMaqs" type="System.Configuration.NameValueSectionHandler" />
<section name="RemoteSeleniumCapsMaqs" type="System.Configuration.NameValueSectionHandler" />
</configSections>
<MagenicMaqs>
<!--For configuration override tests-->
<add key="OverrideTest" value="not overridden" />
<add key="OverrideNUnitTest" value="not overridden" />

<!-- Generic wait time in milliseconds - AKA how long do you wait for rechecking something -->
<add key="WaitTime" value="1000" />
<!-- Generic wait time in milliseconds - AKA how long do you wait for rechecking something -->
<add key="WaitTime" value="1000" />

<!-- Generic time-out in milliseconds -->
<add key="Timeout" value="10000" />
<!-- Generic time-out in milliseconds -->
<add key="Timeout" value="10000" />

<!-- Do you want to create logs for your tests
<!-- Do you want to create logs for your tests
<add key="Log" value="YES"/>
<add key="Log" value="NO"/>
<add key="Log" value="OnFail"/>-->
<add key="Log" value="Yes" />
<add key="Log" value="Yes" />

<!--Logging Levels
<!--Logging Levels
<add key="LogLevel" value="VERBOSE"/>
<add key="LogLevel" value="INFORMATION"/>
<add key="LogLevel" value="GENERIC"/>
<add key="LogLevel" value="SUCCESS"/>
<add key="LogLevel" value="WARNING"/>
<add key="LogLevel" value="ERROR"/>-->
<add key="LogLevel" value="VERBOSE" />
<add key="LogLevel" value="VERBOSE" />

<!-- Logging Types
<!-- Logging Types
<add key="LogType" value="CONSOLE"/>
<add key="LogType" value="TXT"/>
<add key="LogType" value="HTML"/>-->
<add key="LogType" value="TXT" />
<add key="LogType" value="TXT" />

<!-- Log file path - Defaults to build location if no value is defined
<!-- Log file path - Defaults to build location if no value is defined
<add key="FileLoggerPath" value="C:\Frameworks\"/>-->
</MagenicMaqs>
<SeleniumMaqs>
<!--Local browser settings-->
<!--<add key="Browser" value="Chrome"/>-->
<!--<add key="Browser" value="Internet Explorer"/>-->
<!--<add key="Browser" value="Firefox"/>-->
<!--<add key="Browser" value="Edge"/>-->
<add key="Browser" value="HeadlessChrome" />
</MagenicMaqs>
<SeleniumMaqs>
<!--Local browser settings-->
<!--<add key="Browser" value="Chrome"/>-->
<!--<add key="Browser" value="Internet Explorer"/>-->
<!--<add key="Browser" value="Firefox"/>-->
<!--<add key="Browser" value="Edge"/>-->
<add key="Browser" value="HeadlessChrome" />

<!--Remote browser settings-->
<!--<add key="Browser" value="REMOTE"/>-->
<add key="RemoteBrowser" value="Chrome" />
<add key="RemotePlatform" value="Windows 10" />
<add key="HubUrl" value="https://ondemand.saucelabs.com/wd/hub" />
<add key="WebSiteBase" value="https://magenicautomation.azurewebsites.net/" />
<add key="BrowserWaitTime" value="1000" />
<add key="BrowserTimeout" value="20000" />
<add key="SeleniumCommandTimeout" value="200000" />
<!--Remote browser settings-->
<!--<add key="Browser" value="REMOTE"/>-->
<add key="RemoteBrowser" value="Chrome" />
<add key="RemotePlatform" value="Windows 10" />
<add key="HubUrl" value="https://ondemand.saucelabs.com/wd/hub" />
<add key="WebSiteBase" value="https://magenicautomation.azurewebsites.net/" />
<add key="BrowserWaitTime" value="1000" />
<add key="BrowserTimeout" value="20000" />
<add key="SeleniumCommandTimeout" value="200000" />

<!--Browser Resize settings-->
<!--add key="BrowserSize" value="MAXIMIZE"/-->
<!--add key="BrowserSize" value ="DEFAULT"/-->
<add key="BrowserSize" value="1024x768" />
<!--Browser Resize settings-->
<!--add key="BrowserSize" value="MAXIMIZE"/-->
<!--add key="BrowserSize" value ="DEFAULT"/-->
<add key="BrowserSize" value="1024x768" />

<add key="SoftAssertScreenshot" value="Yes" />
<add key="SavePagesourceOnFail" value="Yes" />
<add key="ImageFormat" value="PNG" />
<add key="RetryRefused" value="Yes" />
<add key="SoftAssertScreenshot" value="Yes" />
<add key="SavePagesourceOnFail" value="Yes" />
<add key="ImageFormat" value="PNG" />
<add key="RetryRefused" value="Yes" />

<add key="UseProxy" value="No" />
<add key="ProxyAddress" value="http://localhost:8002" />
<add key="FirefoxVersion" value="0.30.0" />
</SeleniumMaqs>
<RemoteSeleniumCapsMaqs>
<!--<add key="sauce:options" value="{username: 'USER', accessKey: 'KEY'}" />-->
<add key="username" value="magenicMAQSService" />
<add key="accessKey" value="NEVER_ENTER_THIS_VALUE" />
<add key="test:test" value="test" />
</RemoteSeleniumCapsMaqs>
<add key="UseProxy" value="No" />
<add key="ProxyAddress" value="http://localhost:8002" />
<add key="FirefoxVersion" value="0.30.0" />
</SeleniumMaqs>
<RemoteSeleniumCapsMaqs>
<add key="sauce:options">
<add key="username" value="magenicMAQSService" />
<!--<add key="accessKey" value="NEVER_ENTER_THIS_VALUE" />-->
</add>
</RemoteSeleniumCapsMaqs>
</configuration>
Loading

0 comments on commit 278359b

Please sign in to comment.