Skip to content

Commit

Permalink
Merge pull request #7 from ObjectivityBSS/2.1.10
Browse files Browse the repository at this point in the history
Merge release 2.1.10 commits into master
  • Loading branch information
raczeja committed Feb 1, 2016
2 parents f6face5 + 51cc2e0 commit 0e72bc6
Show file tree
Hide file tree
Showing 33 changed files with 229 additions and 149 deletions.
1 change: 1 addition & 0 deletions Objectivity.Test.Automation.Common/App.config
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
<add key="longTimeout" value="30" />
<add key="mediumTimeout" value="10" />
<add key="shortTimeout" value="3" />
<add key="ImplicitlyWaitMilliseconds" value="200" />
<!--User credentials-->
<add key="username" value="null" />
<add key="password" value="null" />
Expand Down
49 changes: 43 additions & 6 deletions Objectivity.Test.Automation.Common/BaseConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,19 +36,19 @@ public static class BaseConfiguration
/// <summary>
/// Gets the Driver.
/// </summary>
public static DriverContext.BrowserType TestBrowser
public static BrowserType TestBrowser
{
get
{
DriverContext.BrowserType browserType;
BrowserType browserType;
bool supportedBrowser = Enum.TryParse(ConfigurationManager.AppSettings["browser"], out browserType);

if (supportedBrowser)
{
return browserType;
}

return DriverContext.BrowserType.None;
return BrowserType.None;
}
}

Expand Down Expand Up @@ -101,29 +101,37 @@ public static string Password
}

/// <summary>
/// Gets the java script or ajax waiting time.
/// Gets the java script or ajax waiting time [seconds].
/// </summary>
public static double MediumTimeout
{
get { return Convert.ToDouble(ConfigurationManager.AppSettings["mediumTimeout"], CultureInfo.CurrentCulture); }
}

/// <summary>
/// Gets the page load waiting time.
/// Gets the page load waiting time [seconds].
/// </summary>
public static double LongTimeout
{
get { return Convert.ToDouble(ConfigurationManager.AppSettings["longTimeout"], CultureInfo.CurrentCulture); }
}

/// <summary>
/// Gets the assertion waiting time.
/// Gets the assertion waiting time [seconds].
/// </summary>
public static double ShortTimeout
{
get { return Convert.ToDouble(ConfigurationManager.AppSettings["shortTimeout"], CultureInfo.CurrentCulture); }
}

/// <summary>
/// Gets the Implicitly Wait time [milliseconds].
/// </summary>
public static double ImplicitlyWaitMilliseconds
{
get { return Convert.ToDouble(ConfigurationManager.AppSettings["ImplicitlyWaitMilliseconds"], CultureInfo.CurrentCulture); }
}

/// <summary>
/// Gets the firefox path
/// </summary>
Expand Down Expand Up @@ -245,5 +253,34 @@ public static string PageSourceFolder
{
get { return ConfigurationManager.AppSettings["PageSourceFolder"]; }
}

/// <summary>
/// Gets the URL value 'Protocol://HostURL'.
/// </summary>
public static string GetUrlValue
{
get
{
return string.Format(CultureInfo.CurrentCulture, "{0}://{1}{2}", Protocol, Host, Url);
}
}

/// <summary>
/// Gets the URL value with user credentials 'Protocol://Username:Password@HostURL'.
/// </summary>
public static string GetUrlValueWithUserCredentials
{
get
{
return string.Format(
CultureInfo.CurrentCulture,
"{0}://{1}:{2}@{3}{4}",
Protocol,
Username,
Password,
Host,
Url);
}
}
}
}
57 changes: 57 additions & 0 deletions Objectivity.Test.Automation.Common/BrowserType.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/*
The MIT License (MIT)
Copyright (c) 2015 Objectivity Bespoke Software Specialists
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/

namespace Objectivity.Test.Automation.Common
{
/// <summary>
/// Supported browsers
/// </summary>
public enum BrowserType
{
/// <summary>
/// Firefox browser
/// </summary>
Firefox,

/// <summary>
/// Firefox portable
/// </summary>
FirefoxPortable,

/// <summary>
/// InternetExplorer browser
/// </summary>
InternetExplorer,

/// <summary>
/// Chrome browser
/// </summary>
Chrome,

/// <summary>
/// Not supported browser
/// </summary>
None
}
}
45 changes: 9 additions & 36 deletions Objectivity.Test.Automation.Common/DriverContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,37 +65,6 @@ public class DriverContext

private TestLogger logTest;

/// <summary>
/// Supported browsers
/// </summary>
public enum BrowserType
{
/// <summary>
/// Firefox browser
/// </summary>
Firefox,

/// <summary>
/// Firefox portable
/// </summary>
FirefoxPortable,

/// <summary>
/// InternetExplorer browser
/// </summary>
InternetExplorer,

/// <summary>
/// Chrome browser
/// </summary>
Chrome,

/// <summary>
/// Not supported browser
/// </summary>
None
}

/// <summary>
/// Gets or sets the test title.
/// </summary>
Expand Down Expand Up @@ -347,8 +316,11 @@ public void Start()
default:
throw new NotSupportedException(
string.Format(CultureInfo.CurrentCulture, "Driver {0} is not supported", BaseConfiguration.TestBrowser));
}

}

this.driver.Manage().Timeouts().SetPageLoadTimeout(TimeSpan.FromSeconds(BaseConfiguration.LongTimeout));
this.driver.Manage().Timeouts().SetScriptTimeout(TimeSpan.FromSeconds(BaseConfiguration.ShortTimeout));
this.driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromMilliseconds(BaseConfiguration.ImplicitlyWaitMilliseconds));
this.driver.Manage().Window.Maximize();
}

Expand All @@ -360,9 +332,10 @@ public void Stop()
this.driver.Quit();
}

/// <summary>
/// Takes the screenshot.
/// </summary>
/// <summary>
/// Takes the screenshot.
/// </summary>
/// <returns>An image of the page currently loaded in the browser.</returns>
public Screenshot TakeScreenshot()
{
try
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ namespace Objectivity.Test.Automation.Common.Exceptions
using System.Runtime.Serialization;

/// <summary>
/// Exception to throw when problem with setting the test case name from parameters
/// The exception that is thrown when the time for a process or operation has expired.
/// </summary>
public class WaitTimeoutException : Exception
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ public static IWebElement GetElement(this ISearchContext element, ElementLocator
}

/// <summary>
/// Finds and waits for an element that meets specified conditions at specified time .
/// Finds and waits for an element that meets specified conditions at specified time, recheck condition at specific time interval.
/// </summary>
/// <param name="element">The element.</param>
/// <param name="locator">The locator.</param>
Expand All @@ -139,7 +139,7 @@ public static IWebElement GetElement(this ISearchContext element, ElementLocator
/// Return found element
/// </returns>
/// <example>How to use it: <code>
/// this.Driver.GetElement(this.loginButton, timeout, e =&gt; e.Displayed);
/// this.Driver.GetElement(this.loginButton, timeout, timeInterval, e =&gt; e.Displayed &amp; e.Enabled);
/// </code></example>
public static IWebElement GetElement(this ISearchContext element, ElementLocator locator, double timeout, double timeInterval, Func<IWebElement, bool> condition, [Optional] string customMessage)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ public static IJavaScriptExecutor JavaScripts(this IWebDriver webDriver)
/// <param name="webDriver">The web driver.</param>
private static void ApproveCertificateForInternetExplorer(this IWebDriver webDriver)
{
if (BaseConfiguration.TestBrowser.Equals(DriverContext.BrowserType.InternetExplorer) && webDriver.Title.Contains("Certificate"))
if (BaseConfiguration.TestBrowser.Equals(BrowserType.InternetExplorer) && webDriver.Title.Contains("Certificate"))
{
webDriver.FindElement(By.Id("overridelink")).JavaScriptClick();
}
Expand Down
2 changes: 1 addition & 1 deletion Objectivity.Test.Automation.Common/Helpers/FilesHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ public static void RenameFile(string oldName, string newName, string subFolder,
/// </summary>
/// <param name="appConfigValue">The application configuration value.</param>
/// <param name="currentFolder">Directory where assembly files are located</param>
/// <returns></returns>
/// <returns>The path to folder</returns>
public static string GetFolder(string appConfigValue, string currentFolder)
{
Logger.Trace(CultureInfo.CurrentCulture, "appConfigValue '{0}', currentFolder '{1}', UseCurrentDirectory '{2}'", appConfigValue, currentFolder, BaseConfiguration.UseCurrentDirectory);
Expand Down
2 changes: 1 addition & 1 deletion Objectivity.Test.Automation.Common/Helpers/MdxHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public static class MdxHelper
/// <param name="command">MDX query string.</param>
/// <param name="connectionString">The Analysis Services connection string.</param>
/// <param name="index">The index of column.</param>
/// <returns></returns>
/// <returns>Collection of MDX query results</returns>
[SuppressMessage("Microsoft.Security", "CA2100:Review SQL queries for security vulnerabilities", Justification = "Mdx injection is in this case expected.")]
public static ICollection<string> ExecuteMdxCommand(string command, string connectionString, int index)
{
Expand Down
17 changes: 13 additions & 4 deletions Objectivity.Test.Automation.Common/Helpers/SqlHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ public static class SqlHelper
[SuppressMessage("Microsoft.Security", "CA2100:Review SQL queries for security vulnerabilities", Justification = "SQL injection is in this case expected.")]
public static ICollection<string> ExecuteSqlCommand(string command, string connectionString, string column)
{
Logger.Trace(CultureInfo.CurrentCulture, "Execute sql query '{0}'", command);

var resultList = new List<string>();

using (var connection = new SqlConnection(connectionString))
Expand All @@ -63,7 +65,7 @@ public static ICollection<string> ExecuteSqlCommand(string command, string conne
{
if (!sqlDataReader.HasRows)
{
Logger.Error("No result for: {0} \n {1}", command, connectionString);
Logger.Error(CultureInfo.CurrentCulture, "No result for: {0} \n {1} \n {2}", command, connectionString, column);
return resultList;
}

Expand All @@ -77,11 +79,11 @@ public static ICollection<string> ExecuteSqlCommand(string command, string conne

if (resultList.Count == 0)
{
Logger.Error("No result for: {0} \n {1}", command, connectionString);
Logger.Error(CultureInfo.CurrentCulture, "No result for: {0} \n {1} \n {2}", command, connectionString, column);
}
else
{
Logger.Trace("sql results: {0}", resultList);
Logger.Trace(CultureInfo.CurrentCulture, "Sql results: {0}", resultList);
}

return resultList;
Expand All @@ -97,6 +99,8 @@ public static ICollection<string> ExecuteSqlCommand(string command, string conne
[SuppressMessage("Microsoft.Security", "CA2100:Review SQL queries for security vulnerabilities", Justification = "SQL injection is in this case expected.")]
public static Dictionary<string, string> ExecuteSqlCommand(string command, string connectionString, IEnumerable<string> columns)
{
Logger.Trace(CultureInfo.CurrentCulture, "Execute sql query '{0}'", command);

var resultList = new Dictionary<string, string>();
var resultTemp = new Dictionary<string, string>();

Expand All @@ -110,7 +114,7 @@ public static Dictionary<string, string> ExecuteSqlCommand(string command, strin
{
if (!sqlDataReader.HasRows)
{
Logger.Error("No result for: {0} \n {1}", command, connectionString);
Logger.Error(CultureInfo.CurrentCulture, "No result for: {0} \n {1}", command, connectionString);
return resultList;
}

Expand Down Expand Up @@ -139,6 +143,11 @@ public static Dictionary<string, string> ExecuteSqlCommand(string command, strin
}
}

foreach (KeyValuePair<string, string> entry in resultList)
{
Logger.Trace(CultureInfo.CurrentCulture, "Sql results: {0} = {1}", entry.Key, entry.Value);
}

return resultList;
}
}
Expand Down
2 changes: 1 addition & 1 deletion Objectivity.Test.Automation.Common/Helpers/WaitHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public static void Wait(Func<bool> condition, TimeSpan timeout, TimeSpan sleepIn

if (!result)
{
throw new WaitTimeoutException(string.Format(CultureInfo.CurrentCulture, "Timeout after {0} second(s), {1}", timeout, message));
throw new WaitTimeoutException(string.Format(CultureInfo.CurrentCulture, "Timeout after {0} second(s), {1}", timeout.Seconds, message));
}
}

Expand Down
2 changes: 2 additions & 0 deletions Objectivity.Test.Automation.Common/Logger/TestLogger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ public class TestLogger
/// <summary>
/// Logs the test starting.
/// </summary>
/// <param name="driverContext">The driver context.</param>
public void LogTestStarting(DriverContext driverContext)
{
this.startTestTime = DateTime.Now;
Expand All @@ -56,6 +57,7 @@ public void LogTestStarting(DriverContext driverContext)
/// <summary>
/// Logs the test ending.
/// </summary>
/// <param name="driverContext">The driver context.</param>
public void LogTestEnding(DriverContext driverContext)
{
var endTestTime = DateTime.Now;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
</ItemGroup>
<ItemGroup>
<Compile Include="BaseConfiguration.cs" />
<Compile Include="BrowserType.cs" />
<Compile Include="DriverContext.cs" />
<Compile Include="Exceptions\WaitTimeoutException.cs" />
<Compile Include="Exceptions\DataDrivenReadException.cs" />
Expand Down Expand Up @@ -113,12 +114,14 @@
<Reference Include="System.Data" />
<Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms" />
<Reference Include="WebDriver, Version=2.48.2.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Selenium.WebDriver.2.48.2\lib\net40\WebDriver.dll</HintPath>
<Reference Include="System.XML" />
<Reference Include="System.Xml.Linq" />
<Reference Include="WebDriver, Version=2.50.1.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Selenium.WebDriver.2.50.1\lib\net40\WebDriver.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="WebDriver.Support, Version=2.48.2.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Selenium.Support.2.48.2\lib\net40\WebDriver.Support.dll</HintPath>
<Reference Include="WebDriver.Support, Version=2.50.1.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Selenium.Support.2.50.1\lib\net40\WebDriver.Support.dll</HintPath>
<Private>True</Private>
</Reference>
</ItemGroup>
Expand Down
Loading

0 comments on commit 0e72bc6

Please sign in to comment.