From 548ecc7f04b0b3b4e83d80b94b38d0e2b5eb9666 Mon Sep 17 00:00:00 2001 From: Jakub Raczek Date: Thu, 12 Jul 2018 09:23:34 +0200 Subject: [PATCH 1/9] Added reference to System.Configuration for NUnit package --- .nuspec/Objectivity.Test.Automation.Nunit.nuspec | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.nuspec/Objectivity.Test.Automation.Nunit.nuspec b/.nuspec/Objectivity.Test.Automation.Nunit.nuspec index 98d61f3aa..bd838c411 100644 --- a/.nuspec/Objectivity.Test.Automation.Nunit.nuspec +++ b/.nuspec/Objectivity.Test.Automation.Nunit.nuspec @@ -26,6 +26,9 @@ + + + From 82108e9074a58ed8fb1ebf4a3aedb5c7f8c59704 Mon Sep 17 00:00:00 2001 From: Jakub Raczek Date: Mon, 16 Jul 2018 08:32:27 +0200 Subject: [PATCH 2/9] fixed description of TakeScreenShotOfElement --- Objectivity.Test.Automation.Common/Helpers/TakeScreenShot.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Objectivity.Test.Automation.Common/Helpers/TakeScreenShot.cs b/Objectivity.Test.Automation.Common/Helpers/TakeScreenShot.cs index 6cef00e82..f254ccf7c 100644 --- a/Objectivity.Test.Automation.Common/Helpers/TakeScreenShot.cs +++ b/Objectivity.Test.Automation.Common/Helpers/TakeScreenShot.cs @@ -110,7 +110,7 @@ public static string Save(Bitmap bitmap, ImageFormat format, string folder, stri /// Full path to taken screenshot /// How to use it: /// var el = this.Driver.GetElement(this.menu); - /// TakeScreenShot.TakeScreenShotOfElement(el, TestContext.CurrentContext.TestDirectory + BaseConfiguration.ScreenShotFolder, "MenuOutSideTheIFrame"); + /// var fullPath = TakeScreenShot.TakeScreenShotOfElement(el, TestContext.CurrentContext.TestDirectory + BaseConfiguration.ScreenShotFolder, "MenuOutSideTheIFrame"); /// public static string TakeScreenShotOfElement(IWebElement element, string folder, string screenshotName) { @@ -133,7 +133,7 @@ public static string TakeScreenShotOfElement(IWebElement element, string folder, /// int y = iFrame.Location.Y; /// this.Driver.SwitchTo().Frame(0); /// var el = this.Driver.GetElement(this.elelemtInIFrame); - /// TakeScreenShot.TakeScreenShotOfElement(el, TestContext.CurrentContext.TestDirectory + BaseConfiguration.ScreenShotFolder, "MenuOutSideTheIFrame"); + /// var fullPath = TakeScreenShot.TakeScreenShotOfElement(x, y, el, TestContext.CurrentContext.TestDirectory + BaseConfiguration.ScreenShotFolder, "MenuOutSideTheIFrame"); /// public static string TakeScreenShotOfElement(int iframeLocationX, int iframeLocationY, IWebElement element, string folder, string screenshotName) { From 503660fc0f7dda9a0bb306e717174027f31bc282 Mon Sep 17 00:00:00 2001 From: Jakub Raczek Date: Thu, 26 Jul 2018 09:09:42 +0200 Subject: [PATCH 3/9] Added log info for Taking Screenshot --- Objectivity.Test.Automation.Common/Helpers/TakeScreenShot.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/Objectivity.Test.Automation.Common/Helpers/TakeScreenShot.cs b/Objectivity.Test.Automation.Common/Helpers/TakeScreenShot.cs index f254ccf7c..595ad451c 100644 --- a/Objectivity.Test.Automation.Common/Helpers/TakeScreenShot.cs +++ b/Objectivity.Test.Automation.Common/Helpers/TakeScreenShot.cs @@ -47,6 +47,7 @@ public static class TakeScreenShot /// Image contains desktop screenshot public static Bitmap DoIt() { + Logger.Info("****************************Taking*Screenshot***************************************"); var screen = Screen.PrimaryScreen; using (var bitmap = new Bitmap(screen.Bounds.Width, screen.Bounds.Height)) { From f3ad3019619364bebabb59419476fc2ec07facd9 Mon Sep 17 00:00:00 2001 From: Jakub Raczek Date: Tue, 28 Aug 2018 15:35:41 +0200 Subject: [PATCH 4/9] Added tests for DynamicallyLoadedPageElements --- .../Tests/HerokuappTestsNUnit.cs | 27 +++++++++++++++++ .../TheInternet/DynamicLoadingPage.cs | 30 ++++++++++++++++--- 2 files changed, 53 insertions(+), 4 deletions(-) diff --git a/Objectivity.Test.Automation.Tests.NUnit/Tests/HerokuappTestsNUnit.cs b/Objectivity.Test.Automation.Tests.NUnit/Tests/HerokuappTestsNUnit.cs index 8846fa6a0..f0279c310 100644 --- a/Objectivity.Test.Automation.Tests.NUnit/Tests/HerokuappTestsNUnit.cs +++ b/Objectivity.Test.Automation.Tests.NUnit/Tests/HerokuappTestsNUnit.cs @@ -27,6 +27,7 @@ namespace Objectivity.Test.Automation.Tests.NUnit.Tests using Common; using DataDriven; using global::NUnit.Framework; + using OpenQA.Selenium; [TestFixture] [Parallelizable(ParallelScope.Fixtures)] @@ -193,5 +194,31 @@ public void DragAndDropTest() Assert.IsTrue(dragAndDrop.IsElementAMovedToB(), "Element is not moved."); } + + [Test] + public void DynamicallyLoadedPageElementsTest() + { + var page = new InternetPage(this.DriverContext) + .OpenHomePage() + .GoToDynamicLoading() + .ClickOnExample2(); + + this.DriverContext.PerformanceMeasures.StartMeasure(); + page.ClickStart(); + Assert.AreEqual(page.Text, "Hello World!"); + this.DriverContext.PerformanceMeasures.StopMeasure(TestContext.CurrentContext.Test.Name + "WaitForTest"); + } + + [Test] + public void DynamicallyLoadedPageElementsTimeOutTest() + { + var page = new InternetPage(this.DriverContext) + .OpenHomePage() + .GoToDynamicLoading() + .ClickOnExample2(); + + page.ClickStart(); + Assert.Throws(() => page.ShortTimeoutText()); + } } } diff --git a/Objectivity.Test.Automation.Tests.PageObjects/PageObjects/TheInternet/DynamicLoadingPage.cs b/Objectivity.Test.Automation.Tests.PageObjects/PageObjects/TheInternet/DynamicLoadingPage.cs index 18060b163..2f042fa87 100644 --- a/Objectivity.Test.Automation.Tests.PageObjects/PageObjects/TheInternet/DynamicLoadingPage.cs +++ b/Objectivity.Test.Automation.Tests.PageObjects/PageObjects/TheInternet/DynamicLoadingPage.cs @@ -23,28 +23,50 @@ namespace Objectivity.Test.Automation.Tests.PageObjects.PageObjects.TheInternet { using Common.Types; + using NLog; using Objectivity.Test.Automation.Common; using Objectivity.Test.Automation.Common.Extensions; using Objectivity.Test.Automation.Tests.PageObjects; public class DynamicLoadingPage : ProjectPageBase { - private readonly ElementLocator exampleLink1 = new ElementLocator(Locator.CssSelector, "a[href='/dynamic_loading/1'"), - startButton = new ElementLocator(Locator.Id, "start"); + private static readonly Logger Logger = LogManager.GetCurrentClassLogger(); + + private readonly ElementLocator exampleLink1 = new ElementLocator(Locator.CssSelector, "a[href='/dynamic_loading/2'"), + startButton = new ElementLocator(Locator.XPath, "//button[.='Start']"), + text = new ElementLocator(Locator.XPath, "//div[@id='finish']/h4"); public DynamicLoadingPage(DriverContext driverContext) : base(driverContext) { } - public void ClickOnExample1() + public string Text + { + get + { + var returnText = this.Driver.GetElement(this.text).Text; + Logger.Debug(returnText); + return returnText; + } + } + + public void ShortTimeoutText() + { + var returnText = this.Driver.GetElement(this.text, BaseConfiguration.ShortTimeout).Text; + Logger.Debug(returnText); + } + + public DynamicLoadingPage ClickOnExample2() { this.Driver.GetElement(this.exampleLink1).Click(); + return this; } - public void ClickStart() + public DynamicLoadingPage ClickStart() { this.Driver.GetElement(this.startButton).Click(); + return this; } } } From 842c6f34d5d295623f98a61a505d01712b42be20 Mon Sep 17 00:00:00 2001 From: Jakub Raczek Date: Wed, 29 Aug 2018 07:49:20 +0200 Subject: [PATCH 5/9] Update appveyor.yml --- appveyor.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index 3a317228a..e16b84bb1 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -244,7 +244,7 @@ test_script: echo $lastexitcode } - echo '********************************************testingbot.com tests********************************************' + <#echo '********************************************testingbot.com tests********************************************' cd .\\scripts @@ -259,7 +259,7 @@ test_script: if($lastexitcode -ne 0) { echo $lastexitcode - } + }#> echo '********************************************saucelabs tests********************************************' From 25560537c1d992afb49dac9cc380d755ec179fcc Mon Sep 17 00:00:00 2001 From: Jakub Raczek Date: Thu, 30 Aug 2018 12:20:56 +0200 Subject: [PATCH 6/9] Added GetElements - Finds and waits for LongTimeout timeout for at least minimum number of elements that are enabled and displayed --- .../Extensions/SearchContextExtensions.cs | 87 ++++++++++++++----- .../Tests/HerokuappTestsDataDrivenNUnit.cs | 2 +- .../TheInternet/ShiftingContentPage.cs | 9 +- 3 files changed, 75 insertions(+), 23 deletions(-) diff --git a/Objectivity.Test.Automation.Common/Extensions/SearchContextExtensions.cs b/Objectivity.Test.Automation.Common/Extensions/SearchContextExtensions.cs index 09d6d001f..02bc12704 100644 --- a/Objectivity.Test.Automation.Common/Extensions/SearchContextExtensions.cs +++ b/Objectivity.Test.Automation.Common/Extensions/SearchContextExtensions.cs @@ -1,23 +1,23 @@ // // Copyright (c) Objectivity Bespoke Software Specialists. All rights reserved. -// -// -// 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. +// +// +// 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. // namespace Objectivity.Test.Automation.Common.Extensions @@ -28,9 +28,8 @@ namespace Objectivity.Test.Automation.Common.Extensions using System.Globalization; using System.Linq; using System.Runtime.InteropServices; - + using Objectivity.Test.Automation.Common.Helpers; using Objectivity.Test.Automation.Common.Types; - using OpenQA.Selenium; using OpenQA.Selenium.Internal; using OpenQA.Selenium.Support.UI; @@ -267,7 +266,7 @@ public static T GetElement(this ISearchContext searchContext, ElementLocator } /// - /// Finds elements that are visible and displayed. + /// Finds elements that are enabled and displayed. /// /// The element. /// The locator. @@ -282,6 +281,52 @@ public static IList GetElements(this ISearchContext element, Elemen return element.GetElements(locator, e => e.Displayed && e.Enabled).ToList(); } + /// + /// Finds and waits for given timeout for at least minimum number of elements that meet specified conditions. + /// + /// The element. + /// The locator. + /// Specified time to wait. + /// Condition to be fulfilled by elements + /// The minimum number of elements to get + /// + /// Return all found and displayed and enabled elements + /// + /// How to find elements : + /// var checkboxes = this.Driver.GetElements(this.stackOverFlowCheckbox, timeout, e => e.Displayed && e.Enabled, 1); + /// + public static IList GetElements(this ISearchContext element, ElementLocator locator, double timeout, Func condition, int minNumberOfElements) + { + IList elements = null; + WaitHelper.Wait( + () => (elements = GetElements(element, locator, condition).ToList()).Count >= minNumberOfElements, + TimeSpan.FromSeconds(timeout), + "Timeout while getting elements"); + return elements; + } + + /// + /// Finds and waits for LongTimeout timeout for at least minimum number of elements that are enabled and displayed. + /// + /// The element. + /// The locator. + /// The minimum number of elements to get + /// + /// Return all found and displayed and enabled elements + /// + /// How to find elements : + /// var checkboxes = this.Driver.GetElements(this.stackOverFlowCheckbox, 1); + /// + public static IList GetElements(this ISearchContext element, ElementLocator locator, int minNumberOfElements) + { + IList elements = null; + WaitHelper.Wait( + () => (elements = GetElements(element, locator, e => e.Displayed && e.Enabled).ToList()).Count >= minNumberOfElements, + TimeSpan.FromSeconds(BaseConfiguration.LongTimeout), + "Timeout while getting elements"); + return elements; + } + /// /// Finds elements that meet specified conditions. /// diff --git a/Objectivity.Test.Automation.Tests.NUnit/Tests/HerokuappTestsDataDrivenNUnit.cs b/Objectivity.Test.Automation.Tests.NUnit/Tests/HerokuappTestsDataDrivenNUnit.cs index abca1d21e..6d58bea18 100644 --- a/Objectivity.Test.Automation.Tests.NUnit/Tests/HerokuappTestsDataDrivenNUnit.cs +++ b/Objectivity.Test.Automation.Tests.NUnit/Tests/HerokuappTestsDataDrivenNUnit.cs @@ -94,7 +94,7 @@ public void CountLinksAndSetTestNameAtShiftingContentExcelTest(IDictionary Assert.AreEqual(parameters["number"], links.CountLinks())); + Verify.That(this.DriverContext, () => Assert.AreEqual(parameters["number"], links.CountLinksGetElementsBasic())); } [Test] diff --git a/Objectivity.Test.Automation.Tests.PageObjects/PageObjects/TheInternet/ShiftingContentPage.cs b/Objectivity.Test.Automation.Tests.PageObjects/PageObjects/TheInternet/ShiftingContentPage.cs index 2284e79f1..d3e008cf0 100644 --- a/Objectivity.Test.Automation.Tests.PageObjects/PageObjects/TheInternet/ShiftingContentPage.cs +++ b/Objectivity.Test.Automation.Tests.PageObjects/PageObjects/TheInternet/ShiftingContentPage.cs @@ -50,7 +50,14 @@ public ShiftingContentPage(DriverContext driverContext) public string CountLinks() { - var count = this.Driver.GetElements(this.links).Count; + var count = this.Driver.GetElements(this.links, BaseConfiguration.ShortTimeout, e => e.Displayed && e.Enabled, 1).Count; + Logger.Info(CultureInfo.CurrentCulture, "Number of links on page '{0}'", count); + return count.ToString(CultureInfo.CurrentCulture); + } + + public string CountLinksGetElementsBasic() + { + var count = this.Driver.GetElements(this.links, 3).Count; Logger.Info(CultureInfo.CurrentCulture, "Number of links on page '{0}'", count); return count.ToString(CultureInfo.CurrentCulture); } From 30029c0871180bc83cbfb8f20011beab588a08ec Mon Sep 17 00:00:00 2001 From: Jakub Raczek Date: Thu, 30 Aug 2018 14:01:31 +0200 Subject: [PATCH 7/9] Updated "EWSoftware.SHFB" version="2018.7.8.1, "Magick.NET-Q16-AnyCPU" version="7.6.0.1" --- .../Objectivity.Test.Automation.UnitTests.csproj | 4 ++-- Objectivity.Test.Automation.UnitTests/packages.config | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Objectivity.Test.Automation.UnitTests/Objectivity.Test.Automation.UnitTests.csproj b/Objectivity.Test.Automation.UnitTests/Objectivity.Test.Automation.UnitTests.csproj index 1f1e47fd0..0ab0ee608 100644 --- a/Objectivity.Test.Automation.UnitTests/Objectivity.Test.Automation.UnitTests.csproj +++ b/Objectivity.Test.Automation.UnitTests/Objectivity.Test.Automation.UnitTests.csproj @@ -40,8 +40,8 @@ 4 - - ..\packages\Magick.NET-Q16-AnyCPU.7.0.3.502\lib\net40-client\Magick.NET-Q16-AnyCPU.dll + + ..\packages\Magick.NET-Q16-AnyCPU.7.6.0.1\lib\net40\Magick.NET-Q16-AnyCPU.dll ..\packages\NLog.4.3.5\lib\net45\NLog.dll diff --git a/Objectivity.Test.Automation.UnitTests/packages.config b/Objectivity.Test.Automation.UnitTests/packages.config index 7e225fa52..72ffaebbc 100644 --- a/Objectivity.Test.Automation.UnitTests/packages.config +++ b/Objectivity.Test.Automation.UnitTests/packages.config @@ -1,8 +1,8 @@  - - - + + + From a3606668cd559a39a4f9c3ad8361383f56944966 Mon Sep 17 00:00:00 2001 From: Jakub Raczek Date: Mon, 3 Sep 2018 09:10:56 +0200 Subject: [PATCH 8/9] Removed FireFoxProfile by FirefoxOptions, installed geckodriver 64 bit --- .../DriverContext.cs | 108 +++++++----------- .../Objectivity.Test.Automation.Common.csproj | 4 +- .../packages.config | 2 +- ...ivity.Test.Automation.Tests.Angular.csproj | 4 +- .../packages.config | 2 +- .../App.config | 2 +- ...vity.Test.Automation.Tests.Features.csproj | 4 +- .../packages.config | 2 +- ...tivity.Test.Automation.Tests.MsTest.csproj | 4 +- .../packages.config | 2 +- ...ctivity.Test.Automation.Tests.NUnit.csproj | 4 +- .../packages.config | 2 +- ...jectivity.Test.Automation.UnitTests.csproj | 4 +- .../packages.config | 2 +- 14 files changed, 60 insertions(+), 86 deletions(-) diff --git a/Objectivity.Test.Automation.Common/DriverContext.cs b/Objectivity.Test.Automation.Common/DriverContext.cs index a0711bd4e..67e862018 100644 --- a/Objectivity.Test.Automation.Common/DriverContext.cs +++ b/Objectivity.Test.Automation.Common/DriverContext.cs @@ -181,11 +181,11 @@ public Collection VerifyMessages /// public string CurrentDirectory { get; set; } - private FirefoxProfile FirefoxProfile + private FirefoxOptions FirefoxOptions { get { - FirefoxProfile profile; + FirefoxOptions options = new FirefoxOptions(); if (BaseConfiguration.UseDefaultFirefoxProfile) { @@ -194,38 +194,41 @@ private FirefoxProfile FirefoxProfile var pathToCurrentUserProfiles = BaseConfiguration.PathToFirefoxProfile; // Path to profile var pathsToProfiles = Directory.GetDirectories(pathToCurrentUserProfiles, "*.default", SearchOption.TopDirectoryOnly); - profile = new FirefoxProfile(pathsToProfiles[0]); + options.Profile = new FirefoxProfile(pathsToProfiles[0]); } catch (DirectoryNotFoundException e) { Logger.Info(CultureInfo.CurrentCulture, "problem with loading firefox profile {0}", e.Message); - profile = new FirefoxProfile(); } } - else - { - profile = new FirefoxProfile(); - } - profile.SetPreference("toolkit.startup.max_resumed_crashes", "999999"); - profile.SetPreference("network.automatic-ntlm-auth.trusted-uris", BaseConfiguration.Host ?? string.Empty); + options.SetPreference("toolkit.startup.max_resumed_crashes", "999999"); + options.SetPreference("network.automatic-ntlm-auth.trusted-uris", BaseConfiguration.Host ?? string.Empty); // retrieving settings from config file var firefoxPreferences = ConfigurationManager.GetSection("FirefoxPreferences") as NameValueCollection; var firefoxExtensions = ConfigurationManager.GetSection("FirefoxExtensions") as NameValueCollection; // preference for downloading files - profile.SetPreference("browser.download.dir", this.DownloadFolder); - profile.SetPreference("browser.download.folderList", 2); - profile.SetPreference("browser.download.managershowWhenStarting", false); - profile.SetPreference("browser.helperApps.neverAsk.saveToDisk", "application/vnd.ms-excel, application/x-msexcel, application/pdf, text/csv, text/html, application/octet-stream"); + options.SetPreference("browser.download.dir", this.DownloadFolder); + options.SetPreference("browser.download.folderList", 2); + options.SetPreference("browser.download.managershowWhenStarting", false); + options.SetPreference("browser.helperApps.neverAsk.saveToDisk", "application/vnd.ms-excel, application/x-msexcel, application/pdf, text/csv, text/html, application/octet-stream"); // disable Firefox's built-in PDF viewer - profile.SetPreference("pdfjs.disabled", true); + options.SetPreference("pdfjs.disabled", true); // disable Adobe Acrobat PDF preview plugin - profile.SetPreference("plugin.scan.Acrobat", "99.0"); - profile.SetPreference("plugin.scan.plid.all", false); + options.SetPreference("plugin.scan.Acrobat", "99.0"); + options.SetPreference("plugin.scan.plid.all", false); + + options.UseLegacyImplementation = BaseConfiguration.FirefoxUseLegacyImplementation; + + // set browser proxy for Firefox + if (!string.IsNullOrEmpty(BaseConfiguration.Proxy)) + { + options.Proxy = this.CurrentProxy(); + } // if there are any extensions if (firefoxExtensions != null) @@ -234,7 +237,7 @@ private FirefoxProfile FirefoxProfile for (var i = 0; i < firefoxExtensions.Count; i++) { Logger.Trace(CultureInfo.CurrentCulture, "Installing extension {0}", firefoxExtensions.GetKey(i)); - profile.AddExtension(firefoxExtensions.GetKey(i)); + options.Profile.AddExtension(firefoxExtensions.GetKey(i)); } } @@ -242,7 +245,7 @@ private FirefoxProfile FirefoxProfile // if there are any settings if (firefoxPreferences == null) { - return profile; + return options; } // loop through all of them @@ -255,12 +258,12 @@ private FirefoxProfile FirefoxProfile { // if current settings value is "true" case "true": - profile.SetPreference(firefoxPreferences.GetKey(i), true); + options.SetPreference(firefoxPreferences.GetKey(i), true); break; // if "false" case "false": - profile.SetPreference(firefoxPreferences.GetKey(i), false); + options.SetPreference(firefoxPreferences.GetKey(i), false); break; // otherwise @@ -270,31 +273,22 @@ private FirefoxProfile FirefoxProfile // an attempt to parse current settings value to an integer. Method TryParse returns True if the attempt is successful (the string is integer) or return False (if the string is just a string and cannot be cast to a number) if (int.TryParse(firefoxPreferences.Get(i), out temp)) { - profile.SetPreference(firefoxPreferences.GetKey(i), temp); + options.SetPreference(firefoxPreferences.GetKey(i), temp); } else { - profile.SetPreference(firefoxPreferences.GetKey(i), firefoxPreferences[i]); + options.SetPreference(firefoxPreferences.GetKey(i), firefoxPreferences[i]); } break; } } - return profile; - } - } - - private FirefoxOptions FirefoxOptions - { - get - { - FirefoxOptions options = new FirefoxOptions(); return options; } } - private ChromeOptions ChromeProfile + private ChromeOptions ChromeOptions { get { @@ -390,7 +384,7 @@ private ChromeOptions ChromeProfile } } - private InternetExplorerOptions InternetExplorerProfile + private InternetExplorerOptions InternetExplorerOptions { get { @@ -437,7 +431,7 @@ private InternetExplorerOptions InternetExplorerProfile } } - private EdgeOptions EdgeProfile + private EdgeOptions EdgeOptions { get { @@ -453,7 +447,7 @@ private EdgeOptions EdgeProfile } } - private SafariOptions SafariProfile + private SafariOptions SafariOptions { get { @@ -498,47 +492,28 @@ public void Start() switch (BaseConfiguration.TestBrowser) { case BrowserType.Firefox: - var fireFoxOptionsLegacy = new FirefoxOptions { Profile = this.FirefoxProfile, UseLegacyImplementation = BaseConfiguration.FirefoxUseLegacyImplementation }; - - // set browser proxy for Firefox - if (!string.IsNullOrEmpty(BaseConfiguration.Proxy)) - { - fireFoxOptionsLegacy.Proxy = this.CurrentProxy(); - } - - fireFoxOptionsLegacy = this.AddFirefoxArguments(fireFoxOptionsLegacy); - - this.driver = new FirefoxDriver(this.SetDriverOptions(fireFoxOptionsLegacy)); + this.driver = new FirefoxDriver(this.SetDriverOptions(this.FirefoxOptions)); break; case BrowserType.FirefoxPortable: - var fireFoxOptions = new FirefoxOptions { BrowserExecutableLocation = BaseConfiguration.FirefoxPath, Profile = this.FirefoxProfile, UseLegacyImplementation = BaseConfiguration.FirefoxUseLegacyImplementation }; - - // set browser proxy for Firefox - if (!string.IsNullOrEmpty(BaseConfiguration.Proxy)) - { - fireFoxOptions.Proxy = this.CurrentProxy(); - } - - fireFoxOptions = this.AddFirefoxArguments(fireFoxOptions); - - this.driver = new FirefoxDriver(this.SetDriverOptions(fireFoxOptions)); + this.FirefoxOptions.BrowserExecutableLocation = BaseConfiguration.FirefoxPath; + this.driver = new FirefoxDriver(this.SetDriverOptions(this.FirefoxOptions)); break; case BrowserType.InternetExplorer: case BrowserType.IE: - this.driver = new InternetExplorerDriver(this.SetDriverOptions(this.InternetExplorerProfile)); + this.driver = new InternetExplorerDriver(this.SetDriverOptions(this.InternetExplorerOptions)); break; case BrowserType.Chrome: - this.driver = new ChromeDriver(this.SetDriverOptions(this.ChromeProfile)); + this.driver = new ChromeDriver(this.SetDriverOptions(this.ChromeOptions)); break; case BrowserType.Safari: - this.driver = new SafariDriver(this.SetDriverOptions(this.SafariProfile)); + this.driver = new SafariDriver(this.SetDriverOptions(this.SafariOptions)); this.CheckIfProxySetForSafari(); break; case BrowserType.RemoteWebDriver: this.driver = new RemoteWebDriver(BaseConfiguration.RemoteWebDriverHub, this.SetCapabilities()); break; case BrowserType.Edge: - this.driver = new EdgeDriver(this.SetDriverOptions(this.EdgeProfile)); + this.driver = new EdgeDriver(this.SetDriverOptions(this.EdgeOptions)); break; default: throw new NotSupportedException( @@ -728,21 +703,20 @@ private DesiredCapabilities SetCapabilities() { case BrowserType.Firefox: capabilities = (DesiredCapabilities)this.SetDriverOptions(this.FirefoxOptions).ToCapabilities(); - capabilities.SetCapability(FirefoxDriver.ProfileCapabilityName, this.FirefoxProfile.ToBase64String()); break; case BrowserType.InternetExplorer: case BrowserType.IE: - capabilities = (DesiredCapabilities)this.SetDriverOptions(this.InternetExplorerProfile).ToCapabilities(); + capabilities = (DesiredCapabilities)this.SetDriverOptions(this.InternetExplorerOptions).ToCapabilities(); break; case BrowserType.Chrome: - capabilities = (DesiredCapabilities)this.SetDriverOptions(this.ChromeProfile).ToCapabilities(); + capabilities = (DesiredCapabilities)this.SetDriverOptions(this.ChromeOptions).ToCapabilities(); break; case BrowserType.Safari: - capabilities = (DesiredCapabilities)this.SetDriverOptions(this.SafariProfile).ToCapabilities(); + capabilities = (DesiredCapabilities)this.SetDriverOptions(this.SafariOptions).ToCapabilities(); this.CheckIfProxySetForSafari(); break; case BrowserType.Edge: - capabilities = (DesiredCapabilities)this.SetDriverOptions(this.EdgeProfile).ToCapabilities(); + capabilities = (DesiredCapabilities)this.SetDriverOptions(this.EdgeOptions).ToCapabilities(); break; case BrowserType.CloudProvider: break; diff --git a/Objectivity.Test.Automation.Common/Objectivity.Test.Automation.Common.csproj b/Objectivity.Test.Automation.Common/Objectivity.Test.Automation.Common.csproj index ccf742013..00e44a409 100644 --- a/Objectivity.Test.Automation.Common/Objectivity.Test.Automation.Common.csproj +++ b/Objectivity.Test.Automation.Common/Objectivity.Test.Automation.Common.csproj @@ -176,9 +176,9 @@ 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}. - + taskkill /F /IM IEDriverServer.exe 2>nul &set errorlevel=0 @@ -187,9 +187,9 @@ taskkill /F /IM geckodriver.exe 2>nul &set errorlevel=0 cd $(TargetDir) del *.log - +