Skip to content

Commit

Permalink
Merge pull request #79 from ObjectivityLtd/3.1.5
Browse files Browse the repository at this point in the history
3.1.5
  • Loading branch information
raczeja committed Jun 22, 2018
2 parents 6ec5c91 + d81e428 commit 44cb691
Show file tree
Hide file tree
Showing 43 changed files with 512 additions and 156 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@
<Argument Key="maxVersionParts" Value="" xmlns="" />
</TransformComponentArguments>
<DocumentationSources>
<DocumentationSource sourceFile="..\packages\Selenium.WebDriver.3.11.0\lib\net45\WebDriver.dll" />
<DocumentationSource sourceFile="..\packages\Selenium.WebDriver.3.11.0\lib\net45\WebDriver.xml" />
<DocumentationSource sourceFile="..\packages\Selenium.Support.3.11.0\lib\net45\WebDriver.Support.dll" />
<DocumentationSource sourceFile="..\packages\Selenium.Support.3.11.0\lib\net45\WebDriver.Support.xml" /></DocumentationSources>
<DocumentationSource sourceFile="..\packages\Selenium.WebDriver.3.12.1\lib\net45\WebDriver.dll" />
<DocumentationSource sourceFile="..\packages\Selenium.WebDriver.3.12.1\lib\net45\WebDriver.xml" />
<DocumentationSource sourceFile="..\packages\Selenium.Support.3.12.1\lib\net45\WebDriver.Support.dll" />
<DocumentationSource sourceFile="..\packages\Selenium.Support.3.12.1\lib\net45\WebDriver.Support.xml" /></DocumentationSources>
<SaveComponentCacheCapacity>100</SaveComponentCacheCapacity>
<BuildAssemblerVerbosity>OnlyWarningsAndErrors</BuildAssemblerVerbosity>
<HelpFileFormat>Website</HelpFileFormat>
Expand Down
4 changes: 4 additions & 0 deletions Objectivity.Test.Automation.Common/App.config
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<section name="nlog" type="NLog.Config.ConfigSectionHandler, NLog"/>
<section name="FirefoxPreferences" type="System.Configuration.NameValueSectionHandler"/>
<section name="FirefoxExtensions" type="System.Configuration.NameValueSectionHandler"/>
<section name="FirefoxArguments" type="System.Configuration.NameValueSectionHandler"/>
<section name="ChromePreferences" type="System.Configuration.NameValueSectionHandler"/>
<section name="ChromeExtensions" type="System.Configuration.NameValueSectionHandler"/>
<section name="DriverCapabilities" type="System.Configuration.NameValueSectionHandler"/>
Expand Down Expand Up @@ -76,6 +77,9 @@
<FirefoxExtensions>
<!-->add key="FirefoxPluginName.xpi" value=""/-->
</FirefoxExtensions>
<FirefoxArguments>
<!--<add key="FirefoxArgument" value=""/>-->
</FirefoxArguments>
<ChromePreferences>
<!--add key="PreferenceToBeOverride" value="NewValue" /-->
</ChromePreferences>
Expand Down
24 changes: 24 additions & 0 deletions Objectivity.Test.Automation.Common/DriverContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,7 @@ private ChromeOptions ChromeProfile

if (BaseConfiguration.ChromePath != null)
{
Logger.Trace(CultureInfo.CurrentCulture, "Setting Chrome Path {0}", BaseConfiguration.ChromePath);
options.BinaryLocation = BaseConfiguration.ChromePath;
}

Expand All @@ -337,6 +338,7 @@ private ChromeOptions ChromeProfile
// loop through all of them
for (var i = 0; i < chromeArguments.Count; i++)
{
Logger.Trace(CultureInfo.CurrentCulture, "Setting Chrome Arguments {0}", chromeArguments.GetKey(i));
options.AddArgument(chromeArguments.GetKey(i));
}
}
Expand Down Expand Up @@ -504,6 +506,8 @@ public void Start()
fireFoxOptionsLegacy.Proxy = this.CurrentProxy();
}

fireFoxOptionsLegacy = this.AddFirefoxArguments(fireFoxOptionsLegacy);

this.driver = new FirefoxDriver(this.SetDriverOptions(fireFoxOptionsLegacy));
break;
case BrowserType.FirefoxPortable:
Expand All @@ -515,6 +519,8 @@ public void Start()
fireFoxOptions.Proxy = this.CurrentProxy();
}

fireFoxOptions = this.AddFirefoxArguments(fireFoxOptions);

this.driver = new FirefoxDriver(this.SetDriverOptions(fireFoxOptions));
break;
case BrowserType.InternetExplorer:
Expand Down Expand Up @@ -829,5 +835,23 @@ private void CheckIfProxySetForSafari()
throw new NotSupportedException("Use command line to setup proxy");
}
}

private FirefoxOptions AddFirefoxArguments(FirefoxOptions option)
{
var firefoxArguments = ConfigurationManager.GetSection("FirefoxArguments") as NameValueCollection;

// if there are any arguments
if (firefoxArguments != null)
{
// loop through all of them
for (var i = 0; i < firefoxArguments.Count; i++)
{
Logger.Trace(CultureInfo.CurrentCulture, "Setting FireFox Arguments {0}", firefoxArguments.GetKey(i));
option.AddArgument(firefoxArguments.GetKey(i));
}
}

return option;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,11 @@ public static IWebDriver ToDriver(this ISearchContext webElement)
var wrappedElement = webElement as IWrapsDriver;
if (wrappedElement == null)
{
if (BaseConfiguration.EnableEventFiringWebDriver)
{
return ((IWrapsElement)webElement).WrappedElement.ToDriver();
}

return (IWebDriver)webElement;
}

Expand Down
64 changes: 42 additions & 22 deletions Objectivity.Test.Automation.Common/Helpers/FilesHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -361,11 +361,11 @@ public static void WaitForFileOfGivenType(FileType type, double waitTime, int fi

if (checkSize)
{
Logger.Debug("Checking if size of last file > 0 bytes");
timeoutMessage = "Checking if size of last file > 0 bytes";
Logger.Debug("Checking if size of last file of given type {0} > 0 bytes", type);
timeoutMessage = string.Format(CultureInfo.CurrentCulture, "Checking if size of last file of given type {0} > 0 bytes", type);

WaitHelper.Wait(
() => GetLastFile(folder).Length > 0, TimeSpan.FromSeconds(waitTime), TimeSpan.FromSeconds(1), timeoutMessage);
() => GetLastFile(folder, type).Length > 0, TimeSpan.FromSeconds(waitTime), TimeSpan.FromSeconds(1), timeoutMessage);
}
}

Expand Down Expand Up @@ -522,11 +522,13 @@ public static string RenameFile(double waitTime, string oldName, string newName,
{
Logger.Debug(CultureInfo.CurrentCulture, "new file name: {0}", newName);

newName = NameHelper.ShortenFileName(subFolder, newName, "_", 255);
newName = NameHelper.ShortenFileName(subFolder, newName, "_", 255);

string fullPath = Path.Combine(subFolder, newName);

if (File.Exists(newName))
if (File.Exists(fullPath))
{
File.Delete(newName);
File.Delete(fullPath);
}

// Use ProcessStartInfo class
Expand Down Expand Up @@ -572,26 +574,26 @@ public static string CopyFile(double waitTime, string oldName, string newName, s
/// <returns>The new name in case its shorten</returns>
/// <example>How to use it: <code>
/// FilesHelper.CopyFile(BaseConfiguration.ShortTimeout, fileName, newName, this.DriverContext.DownloadFolder + "\\", this.DriverContext.DownloadFolder + "\\");
/// </code></example>
public static string CopyFile(double waitTime, string oldName, string newName, string oldSubFolder, string newSubFolder)
{
Logger.Debug(CultureInfo.CurrentCulture, "new file name: {0}\\{1}", newSubFolder, newName);

newName = NameHelper.ShortenFileName(newSubFolder, newName, "_", 255);

if (File.Exists(newSubFolder + Separator + newName))
{
File.Delete(newSubFolder + Separator + newName);
}

// Use ProcessStartInfo class
string command = "/c copy " + '\u0022' + oldName + '\u0022' + " " + '\u0022' + newSubFolder + Separator + newName +
'\u0022';
/// </code></example>
public static string CopyFile(double waitTime, string oldName, string newName, string oldSubFolder, string newSubFolder)
{
Logger.Debug(CultureInfo.CurrentCulture, "new file name: {0}\\{1}", newSubFolder, newName);

newName = NameHelper.ShortenFileName(newSubFolder, newName, "_", 255);

if (File.Exists(newSubFolder + Separator + newName))
{
File.Delete(newSubFolder + Separator + newName);
}

// Use ProcessStartInfo class
string command = "/c copy " + '\u0022' + oldName + '\u0022' + " " + '\u0022' + newSubFolder + Separator + newName +
'\u0022';
ProcessStartInfo cmdsi = new ProcessStartInfo("cmd.exe")
{
WorkingDirectory = oldSubFolder,
Arguments = command
};
};
Thread.Sleep(1000);

var timeoutMessage = string.Format(CultureInfo.CurrentCulture, "Waiting till file will be copied {0}", newSubFolder);
Expand All @@ -600,6 +602,24 @@ public static string CopyFile(double waitTime, string oldName, string newName, s
return newName;
}

/// <summary>
/// Delete file in given folder if exists.
/// </summary>
/// <param name="name">The name of file.</param>
/// <param name="subFolder">The subFolder.</param>
/// <example>How to use it: <code>
/// FilesHelper.DeleteFile("filename.txt", this.DriverContext.DownloadFolder);
/// </code></example>
public static void DeleteFile(string name, string subFolder)
{
string fullPath = Path.Combine(subFolder, name);

if (File.Exists(fullPath))
{
File.Delete(fullPath);
}
}

/// <summary>
/// Rename the file of given type and check if file was renamed with ShortTimeout, shorten the name of file if needed be removing "_".
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ protected override void OnElementClicking(WebElementEventArgs e)
/// Raises the <see cref="E:ElementValueChanging" /> event.
/// </summary>
/// <param name="e">The <see cref="WebElementEventArgs"/> instance containing the event data.</param>
protected override void OnElementValueChanging(WebElementEventArgs e)
protected override void OnElementValueChanging(WebElementValueEventArgs e)
{
Logger.Trace(CultureInfo.CurrentCulture, "On Element Value Changing: {0}", ToStringElement(e));
base.OnElementValueChanging(e);
Expand All @@ -77,10 +77,10 @@ protected override void OnElementValueChanging(WebElementEventArgs e)
/// Raises the <see cref="E:ElementValueChanged" /> event.
/// </summary>
/// <param name="e">The <see cref="WebElementEventArgs"/> instance containing the event data.</param>
protected override void OnElementValueChanged(WebElementEventArgs e)
protected override void OnElementValueChanged(WebElementValueEventArgs e)
{
Logger.Trace(CultureInfo.CurrentCulture, "On Element Value Changed: {0}", ToStringElement(e));
base.OnElementValueChanged(e);
base.OnElementValueChanging(e);
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,13 +127,11 @@
<Reference Include="System.Windows.Forms" />
<Reference Include="System.XML" />
<Reference Include="System.Xml.Linq" />
<Reference Include="WebDriver, Version=3.11.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Selenium.WebDriver.3.11.0\lib\net45\WebDriver.dll</HintPath>
<Private>True</Private>
<Reference Include="WebDriver, Version=3.12.1.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Selenium.WebDriver.3.12.1\lib\net45\WebDriver.dll</HintPath>
</Reference>
<Reference Include="WebDriver.Support, Version=3.11.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Selenium.Support.3.11.0\lib\net45\WebDriver.Support.dll</HintPath>
<Private>True</Private>
<Reference Include="WebDriver.Support, Version=3.12.1.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Selenium.Support.3.12.1\lib\net45\WebDriver.Support.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
Expand Down Expand Up @@ -178,20 +176,20 @@
<ErrorText>This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('$(SolutionDir)\.nuget\NuGet.targets')" Text="$([System.String]::Format('$(ErrorText)', '$(SolutionDir)\.nuget\NuGet.targets'))" />
<Error Condition="!Exists('..\packages\Selenium.WebDriver.GeckoDriver.0.20.0\build\Selenium.WebDriver.GeckoDriver.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Selenium.WebDriver.GeckoDriver.0.20.0\build\Selenium.WebDriver.GeckoDriver.targets'))" />
<Error Condition="!Exists('..\packages\Selenium.WebDriver.IEDriver.3.11.1\build\Selenium.WebDriver.IEDriver.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Selenium.WebDriver.IEDriver.3.11.1\build\Selenium.WebDriver.IEDriver.targets'))" />
<Error Condition="!Exists('..\packages\Selenium.WebDriver.ChromeDriver.2.36.0\build\Selenium.WebDriver.ChromeDriver.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Selenium.WebDriver.ChromeDriver.2.36.0\build\Selenium.WebDriver.ChromeDriver.targets'))" />
<Error Condition="!Exists('..\packages\Selenium.WebDriver.GeckoDriver.0.20.1\build\Selenium.WebDriver.GeckoDriver.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Selenium.WebDriver.GeckoDriver.0.20.1\build\Selenium.WebDriver.GeckoDriver.targets'))" />
<Error Condition="!Exists('..\packages\Selenium.WebDriver.IEDriver.3.12.0\build\Selenium.WebDriver.IEDriver.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Selenium.WebDriver.IEDriver.3.12.0\build\Selenium.WebDriver.IEDriver.targets'))" />
<Error Condition="!Exists('..\packages\Selenium.WebDriver.ChromeDriver.2.38.0.1\build\Selenium.WebDriver.ChromeDriver.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Selenium.WebDriver.ChromeDriver.2.38.0.1\build\Selenium.WebDriver.ChromeDriver.targets'))" />
</Target>
<Import Project="..\packages\Selenium.WebDriver.GeckoDriver.0.20.0\build\Selenium.WebDriver.GeckoDriver.targets" Condition="Exists('..\packages\Selenium.WebDriver.GeckoDriver.0.20.0\build\Selenium.WebDriver.GeckoDriver.targets')" />
<Import Project="..\packages\Selenium.WebDriver.IEDriver.3.11.1\build\Selenium.WebDriver.IEDriver.targets" Condition="Exists('..\packages\Selenium.WebDriver.IEDriver.3.11.1\build\Selenium.WebDriver.IEDriver.targets')" />
<Import Project="..\packages\Selenium.WebDriver.ChromeDriver.2.36.0\build\Selenium.WebDriver.ChromeDriver.targets" Condition="Exists('..\packages\Selenium.WebDriver.ChromeDriver.2.36.0\build\Selenium.WebDriver.ChromeDriver.targets')" />
<PropertyGroup>
<PreBuildEvent>taskkill /F /IM IEDriverServer.exe 2&gt;nul &amp;set errorlevel=0
taskkill /F /IM chromedriver.exe 2&gt;nul &amp;set errorlevel=0
taskkill /F /IM geckodriver.exe 2&gt;nul &amp;set errorlevel=0
cd $(TargetDir)
del *.log</PreBuildEvent>
</PropertyGroup>
<Import Project="..\packages\Selenium.WebDriver.GeckoDriver.0.20.1\build\Selenium.WebDriver.GeckoDriver.targets" Condition="Exists('..\packages\Selenium.WebDriver.GeckoDriver.0.20.1\build\Selenium.WebDriver.GeckoDriver.targets')" />
<Import Project="..\packages\Selenium.WebDriver.IEDriver.3.12.0\build\Selenium.WebDriver.IEDriver.targets" Condition="Exists('..\packages\Selenium.WebDriver.IEDriver.3.12.0\build\Selenium.WebDriver.IEDriver.targets')" />
<Import Project="..\packages\Selenium.WebDriver.ChromeDriver.2.38.0.1\build\Selenium.WebDriver.ChromeDriver.targets" Condition="Exists('..\packages\Selenium.WebDriver.ChromeDriver.2.38.0.1\build\Selenium.WebDriver.ChromeDriver.targets')" />
<!-- 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.
<Target Name="BeforeBuild">
Expand Down
46 changes: 26 additions & 20 deletions Objectivity.Test.Automation.Common/WebElements/Table.cs
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
// <copyright file="Table.cs" company="Objectivity Bespoke Software Specialists">
// Copyright (c) Objectivity Bespoke Software Specialists. All rights reserved.
// </copyright>
// <license>
// The MIT License (MIT)
// 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.
// </copyright>
// <license>
// The MIT License (MIT)
// 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.
// </license>

namespace Objectivity.Test.Automation.Common.WebElements
{
using NLog;
using Objectivity.Test.Automation.Common.Extensions;
using Objectivity.Test.Automation.Common.Types;

using OpenQA.Selenium;
using OpenQA.Selenium.Remote;

Expand All @@ -33,6 +33,8 @@ namespace Objectivity.Test.Automation.Common.WebElements
/// </summary>
public class Table : RemoteWebElement
{
private static readonly NLog.Logger Logger = LogManager.GetLogger("DRIVER");

/// <summary>
/// The web element
/// </summary>
Expand Down Expand Up @@ -72,8 +74,12 @@ public string[][] GetTable(ElementLocator rowLocator, ElementLocator columnLocat
var j = 0;
foreach (var cell in cells)
{
result[i][j++] = cell.Text;
var cellValue = cell.Text;
Logger.Debug("Table cell Row {0}, column {1}, Value: {2}", i, j, cellValue);
result[i][j++] = cellValue;
}

i++;
}

return result;
Expand Down
Loading

0 comments on commit 44cb691

Please sign in to comment.