diff --git a/Aquality.Selenium/src/Aquality.Selenium/Aquality.Selenium.csproj b/Aquality.Selenium/src/Aquality.Selenium/Aquality.Selenium.csproj
index 4bf7e505..de963765 100644
--- a/Aquality.Selenium/src/Aquality.Selenium/Aquality.Selenium.csproj
+++ b/Aquality.Selenium/src/Aquality.Selenium/Aquality.Selenium.csproj
@@ -20,9 +20,11 @@
Aquality.Selenium.xml
+ 1591
+
@@ -59,6 +61,7 @@
+
@@ -66,7 +69,7 @@
-
+
diff --git a/Aquality.Selenium/src/Aquality.Selenium/Aquality.Selenium.xml b/Aquality.Selenium/src/Aquality.Selenium/Aquality.Selenium.xml
index 381618a9..f11c8b41 100644
--- a/Aquality.Selenium/src/Aquality.Selenium/Aquality.Selenium.xml
+++ b/Aquality.Selenium/src/Aquality.Selenium/Aquality.Selenium.xml
@@ -87,7 +87,7 @@
Sets Selenium WebDriver ImplicitWait timeout.
- Default value: .
+ Default value: .
Desired Implicit wait timeout.
@@ -330,7 +330,7 @@
- Factory that creates instance of desired Browser based on .
+ Factory that creates instance of desired Browser based on .
@@ -510,6 +510,17 @@
JSON settings file.
+
+
+ Settings specific for Edge(chromium) web driver.
+
+
+
+
+ Instantiates class using JSON file with general settings
+
+ JSON settings file.
+
Settings specific for Edge web driver.
@@ -654,7 +665,12 @@
Performs click on element.
-
+
+
+ Highlights the element.
+ Default value is from configuration:
+
+
Scrolling page to the element.
@@ -739,6 +755,333 @@
Moves mouse to the element.
+
+
+ Moves mouse from this element.
+
+
+
+
+ Represents action keys which could be used to .
+ Used to enhance logging of SendKeys actions
+ Directly related to
+
+
+
+
+ Represents the NUL keystroke.
+
+
+
+
+ Represents the number pad 0 key.
+
+
+
+
+ Represents the number pad 1 key.
+
+
+
+
+ Represents the number pad 2 key.
+
+
+
+
+ Represents the number pad 3 key.
+
+
+
+
+ Represents the number pad 4 key.
+
+
+
+
+ Represents the number pad 5 key.
+
+
+
+
+ Represents the number pad 6 key.
+
+
+
+
+ Represents the number pad 7 key.
+
+
+
+
+ Represents the number pad 8 key.
+
+
+
+
+ Represents the number pad 9 key.
+
+
+
+
+ Represents the number pad multiplication key.
+
+
+
+
+ Represents the number pad addition key.
+
+
+
+
+ Represents the number pad thousands separator key.
+
+
+
+
+ Represents the equal sign key.
+
+
+
+
+ Represents the number pad subtraction key.
+
+
+
+
+ Represents the number pad division key.
+
+
+
+
+ Represents the function key F1.
+
+
+
+
+ Represents the function key F2.
+
+
+
+
+ Represents the function key F3.
+
+
+
+
+ Represents the function key F4.
+
+
+
+
+ Represents the function key F5.
+
+
+
+
+ Represents the function key F6.
+
+
+
+
+ Represents the function key F7.
+
+
+
+
+ Represents the function key F8.
+
+
+
+
+ Represents the function key F9.
+
+
+
+
+ Represents the function key F10.
+
+
+
+
+ Represents the function key F11.
+
+
+
+
+ Represents the function key F12.
+
+
+
+
+ Represents the number pad decimal separator key.
+
+
+
+
+ Represents the function key META.
+
+
+
+
+ Represents the semi-colon key.
+
+
+
+
+ Represents the Insert key.
+
+
+
+
+ Represents the Cancel keystroke.
+
+
+
+
+ Represents the Help keystroke.
+
+
+
+
+ Represents the Backspace key.
+
+
+
+
+ Represents the Tab key.
+
+
+
+
+ Represents the Clear keystroke.
+
+
+
+
+ Represents the Return key.
+
+
+
+
+ Represents the Enter key.
+
+
+
+
+ Represents the Shift key.
+
+
+
+
+ Represents the Shift key.
+
+
+
+
+ Represents the Control key.
+
+
+
+
+ Represents the Control key.
+
+
+
+
+ Represents the Alt key.
+
+
+
+
+ Represents the Alt key.
+
+
+
+
+ Represents the Delete key.
+
+
+
+
+ Represents the Pause key.
+
+
+
+
+ Represents the Spacebar key.
+
+
+
+
+ Represents the Page Up key.
+
+
+
+
+ Represents the Page Down key.
+
+
+
+
+ Represents the End key.
+
+
+
+
+ Represents the Home key.
+
+
+
+
+ Represents the left arrow key.
+
+
+
+
+ Represents the left arrow key.
+
+
+
+
+ Represents the up arrow key.
+
+
+
+
+ Represents the up arrow key.
+
+
+
+
+ Represents the right arrow key.
+
+
+
+
+ Represents the right arrow key.
+
+
+
+
+ Represents the Left arrow key.
+
+
+
+
+ Represents the Left arrow key.
+
+
+
+
+ Represents the Escape key.
+
+
+
+
+ Represents the function key COMMAND.
+
+
Defines Button UI element.
@@ -968,6 +1311,12 @@
Value to set.
+
+
+ Send key.
+
+ Key for sending.
+
Defines the interface used to create the elements.
diff --git a/Aquality.Selenium/src/Aquality.Selenium/Browsers/AqualityServices.cs b/Aquality.Selenium/src/Aquality.Selenium/Browsers/AqualityServices.cs
index f2c18582..90ba4916 100644
--- a/Aquality.Selenium/src/Aquality.Selenium/Browsers/AqualityServices.cs
+++ b/Aquality.Selenium/src/Aquality.Selenium/Browsers/AqualityServices.cs
@@ -6,6 +6,7 @@
using Aquality.Selenium.Core.Localization;
using Aquality.Selenium.Core.Logging;
using Aquality.Selenium.Core.Waitings;
+using Aquality.Selenium.Core.Utilities;
namespace Aquality.Selenium.Browsers
{
@@ -90,11 +91,11 @@ public static void SetDefaultFactory()
IBrowserFactory applicationFactory;
if (appProfile.IsRemote)
{
- applicationFactory = new RemoteBrowserFactory();
+ applicationFactory = new RemoteBrowserFactory(Get(), Get(), Get(), LocalizedLogger);
}
else
{
- applicationFactory = new LocalBrowserFactory();
+ applicationFactory = new LocalBrowserFactory(Get(), Get(), Get(), LocalizedLogger);
}
BrowserFactory = applicationFactory;
diff --git a/Aquality.Selenium/src/Aquality.Selenium/Browsers/Browser.cs b/Aquality.Selenium/src/Aquality.Selenium/Browsers/Browser.cs
index 208694e5..6dc438c1 100644
--- a/Aquality.Selenium/src/Aquality.Selenium/Browsers/Browser.cs
+++ b/Aquality.Selenium/src/Aquality.Selenium/Browsers/Browser.cs
@@ -58,7 +58,7 @@ public Browser(RemoteWebDriver webDriver)
///
/// Sets Selenium WebDriver ImplicitWait timeout.
- /// Default value: .
+ /// Default value: .
///
/// Desired Implicit wait timeout.
public void SetImplicitWaitTimeout(TimeSpan timeout)
@@ -109,7 +109,9 @@ public string CurrentUrl
get
{
Logger.Info("loc.browser.getUrl");
- return Driver.Url;
+ var url = Driver.Url;
+ Logger.Info("loc.browser.url.value", url);
+ return url;
}
}
@@ -192,11 +194,13 @@ public IBrowserTabNavigation Tabs()
/// Thrown when no alert found.
public void HandleAlert(AlertAction alertAction, string text = null)
{
+ Logger.Info($"loc.browser.alert.{alertAction.ToString().ToLower()}");
try
{
var alert = Driver.SwitchTo().Alert();
if (!string.IsNullOrEmpty(text))
{
+ Logger.Info("loc.send.text", text);
alert.SendKeys(text);
}
if (alertAction.Equals(AlertAction.Accept))
@@ -230,6 +234,7 @@ public void Maximize()
/// Throws when timeout exceeded and page is not loaded.
public void WaitForPageToLoad()
{
+ Logger.Info("loc.browser.page.wait");
var errorMessage = LocalizationManager.GetLocalizedMessage("loc.browser.page.timeout");
conditionalWait.WaitForTrue(() => ExecuteScript(JavaScript.IsPageLoaded), pageLoadTimeout, message: errorMessage);
}
diff --git a/Aquality.Selenium/src/Aquality.Selenium/Browsers/BrowserFactory.cs b/Aquality.Selenium/src/Aquality.Selenium/Browsers/BrowserFactory.cs
index c1432ad4..eaa644cb 100644
--- a/Aquality.Selenium/src/Aquality.Selenium/Browsers/BrowserFactory.cs
+++ b/Aquality.Selenium/src/Aquality.Selenium/Browsers/BrowserFactory.cs
@@ -1,14 +1,39 @@
-namespace Aquality.Selenium.Browsers
+using Aquality.Selenium.Configurations;
+using Aquality.Selenium.Core.Localization;
+using Aquality.Selenium.Core.Utilities;
+using OpenQA.Selenium;
+using OpenQA.Selenium.Remote;
+
+namespace Aquality.Selenium.Browsers
{
///
/// Abstract representation of .
///
public abstract class BrowserFactory : IBrowserFactory
{
- protected BrowserFactory()
+ protected BrowserFactory(IActionRetrier actionRetrier, IBrowserProfile browserProfile, ITimeoutConfiguration timeoutConfiguration, ILocalizedLogger localizedLogger)
{
+ ActionRetrier = actionRetrier;
+ BrowserProfile = browserProfile;
+ TimeoutConfiguration = timeoutConfiguration;
+ LocalizedLogger = localizedLogger;
}
- public abstract Browser Browser { get; }
+ protected IActionRetrier ActionRetrier { get; }
+ protected IBrowserProfile BrowserProfile { get; }
+ protected ITimeoutConfiguration TimeoutConfiguration { get; }
+ protected ILocalizedLogger LocalizedLogger { get; }
+
+ protected abstract RemoteWebDriver Driver { get; }
+
+ public virtual Browser Browser
+ {
+ get
+ {
+ var browser = new Browser(ActionRetrier.DoWithRetry(() => Driver, new[] { typeof(WebDriverException) }));
+ LocalizedLogger.Info("loc.browser.ready", BrowserProfile.BrowserName);
+ return browser;
+ }
+ }
}
}
diff --git a/Aquality.Selenium/src/Aquality.Selenium/Browsers/IBrowserFactory.cs b/Aquality.Selenium/src/Aquality.Selenium/Browsers/IBrowserFactory.cs
index 3ecfd09a..9a838706 100644
--- a/Aquality.Selenium/src/Aquality.Selenium/Browsers/IBrowserFactory.cs
+++ b/Aquality.Selenium/src/Aquality.Selenium/Browsers/IBrowserFactory.cs
@@ -1,7 +1,7 @@
namespace Aquality.Selenium.Browsers
{
///
- /// Factory that creates instance of desired Browser based on .
+ /// Factory that creates instance of desired Browser based on .
///
public interface IBrowserFactory
{
diff --git a/Aquality.Selenium/src/Aquality.Selenium/Browsers/LocalBrowserFactory.cs b/Aquality.Selenium/src/Aquality.Selenium/Browsers/LocalBrowserFactory.cs
index e7f7a5ca..5863f461 100644
--- a/Aquality.Selenium/src/Aquality.Selenium/Browsers/LocalBrowserFactory.cs
+++ b/Aquality.Selenium/src/Aquality.Selenium/Browsers/LocalBrowserFactory.cs
@@ -17,6 +17,7 @@
using EdgeChromiumOptions = Microsoft.Edge.SeleniumTools.EdgeOptions;
using EdgeChromiumService = Microsoft.Edge.SeleniumTools.EdgeDriverService;
using EdgeChromiumDriver = Microsoft.Edge.SeleniumTools.EdgeDriver;
+using Aquality.Selenium.Core.Localization;
namespace Aquality.Selenium.Browsers
{
@@ -27,61 +28,60 @@ public class LocalBrowserFactory : BrowserFactory
{
private static readonly object WebDriverDownloadingLock = new object();
- public LocalBrowserFactory() : base()
+ public LocalBrowserFactory(IActionRetrier actionRetrier, IBrowserProfile browserProfile, ITimeoutConfiguration timeoutConfiguration, ILocalizedLogger localizedLogger)
+ : base(actionRetrier, browserProfile, timeoutConfiguration, localizedLogger)
{
}
- public override Browser Browser => CreateBrowser();
-
- private Browser CreateBrowser()
+ protected override RemoteWebDriver Driver
{
- var browserProfile = AqualityServices.Get();
- var commandTimeout = AqualityServices.Get().Command;
- var browserName = browserProfile.BrowserName;
- var driverSettings = browserProfile.DriverSettings;
- RemoteWebDriver driver;
- switch (browserName)
+ get
{
- case BrowserName.Chrome:
- SetUpDriver(new ChromeConfig(), driverSettings);
- driver = GetDriver(ChromeDriverService.CreateDefaultService(),
- (ChromeOptions)driverSettings.DriverOptions, commandTimeout);
- break;
- case BrowserName.Firefox:
- SetUpDriver(new FirefoxConfig(), driverSettings);
- var geckoService = FirefoxDriverService.CreateDefaultService();
- geckoService.Host = "::1";
- driver = GetDriver(geckoService, (FirefoxOptions)driverSettings.DriverOptions, commandTimeout);
- break;
- case BrowserName.IExplorer:
- SetUpDriver(new InternetExplorerConfig(), driverSettings);
- driver = GetDriver(InternetExplorerDriverService.CreateDefaultService(),
- (InternetExplorerOptions)driverSettings.DriverOptions, commandTimeout);
- break;
- case BrowserName.Edge:
- driver = GetDriver(EdgeDriverService.CreateDefaultService(),
- (EdgeOptions)driverSettings.DriverOptions, commandTimeout);
- break;
- case BrowserName.EdgeChromium:
- SetUpDriver(new EdgeConfig(), driverSettings);
- driver = GetDriver(EdgeChromiumService.CreateChromiumService(),
- (EdgeChromiumOptions)driverSettings.DriverOptions, commandTimeout);
- break;
- case BrowserName.Safari:
- driver = GetDriver(SafariDriverService.CreateDefaultService(),
- (SafariOptions)driverSettings.DriverOptions, commandTimeout);
- break;
- default:
- throw new ArgumentOutOfRangeException($"Browser {browserName} is not supported.");
+ var commandTimeout = TimeoutConfiguration.Command;
+ var browserName = BrowserProfile.BrowserName;
+ var driverSettings = BrowserProfile.DriverSettings;
+ RemoteWebDriver driver;
+ switch (browserName)
+ {
+ case BrowserName.Chrome:
+ SetUpDriver(new ChromeConfig(), driverSettings);
+ driver = GetDriver(ChromeDriverService.CreateDefaultService(),
+ (ChromeOptions)driverSettings.DriverOptions, commandTimeout);
+ break;
+ case BrowserName.Firefox:
+ SetUpDriver(new FirefoxConfig(), driverSettings);
+ var geckoService = FirefoxDriverService.CreateDefaultService();
+ geckoService.Host = "::1";
+ driver = GetDriver(geckoService, (FirefoxOptions)driverSettings.DriverOptions, commandTimeout);
+ break;
+ case BrowserName.IExplorer:
+ SetUpDriver(new InternetExplorerConfig(), driverSettings);
+ driver = GetDriver(InternetExplorerDriverService.CreateDefaultService(),
+ (InternetExplorerOptions)driverSettings.DriverOptions, commandTimeout);
+ break;
+ case BrowserName.Edge:
+ driver = GetDriver(EdgeDriverService.CreateDefaultService(),
+ (EdgeOptions)driverSettings.DriverOptions, commandTimeout);
+ break;
+ case BrowserName.EdgeChromium:
+ SetUpDriver(new EdgeConfig(), driverSettings);
+ driver = GetDriver(EdgeChromiumService.CreateChromiumService(),
+ (EdgeChromiumOptions)driverSettings.DriverOptions, commandTimeout);
+ break;
+ case BrowserName.Safari:
+ driver = GetDriver(SafariDriverService.CreateDefaultService(),
+ (SafariOptions)driverSettings.DriverOptions, commandTimeout);
+ break;
+ default:
+ throw new NotSupportedException($"Browser [{browserName}] is not supported.");
+ }
+ return driver;
}
-
- return new Browser(driver);
}
private RemoteWebDriver GetDriver(DriverService driverService, DriverOptions driverOptions, TimeSpan commandTimeout) where T : RemoteWebDriver
{
- return AqualityServices.Get().DoWithRetry(() =>
- (T)Activator.CreateInstance(typeof(T), driverService, driverOptions, commandTimeout));
+ return (T) Activator.CreateInstance(typeof(T), driverService, driverOptions, commandTimeout);
}
private static void SetUpDriver(IDriverConfig driverConfig, IDriverSettings driverSettings)
diff --git a/Aquality.Selenium/src/Aquality.Selenium/Browsers/RemoteBrowserFactory.cs b/Aquality.Selenium/src/Aquality.Selenium/Browsers/RemoteBrowserFactory.cs
index 4b4025de..4eda7a4b 100644
--- a/Aquality.Selenium/src/Aquality.Selenium/Browsers/RemoteBrowserFactory.cs
+++ b/Aquality.Selenium/src/Aquality.Selenium/Browsers/RemoteBrowserFactory.cs
@@ -1,4 +1,5 @@
using Aquality.Selenium.Configurations;
+using Aquality.Selenium.Core.Localization;
using Aquality.Selenium.Core.Utilities;
using OpenQA.Selenium.Remote;
using System;
@@ -10,21 +11,26 @@ namespace Aquality.Selenium.Browsers
///
public class RemoteBrowserFactory : BrowserFactory
{
- public RemoteBrowserFactory() : base()
+ public RemoteBrowserFactory(IActionRetrier actionRetrier, IBrowserProfile browserProfile, ITimeoutConfiguration timeoutConfiguration, ILocalizedLogger localizedLogger)
+ : base(actionRetrier, browserProfile, timeoutConfiguration, localizedLogger)
{
}
- public override Browser Browser
+ protected override RemoteWebDriver Driver
{
get
{
- var browserProfile = AqualityServices.Get();
- var capabilities = browserProfile.DriverSettings.DriverOptions.ToCapabilities();
- var timeoutConfiguration = AqualityServices.Get();
- var driver = AqualityServices.Get().DoWithRetry(() =>
- (RemoteWebDriver)Activator.CreateInstance(typeof(RemoteWebDriver),
- browserProfile.RemoteConnectionUrl, capabilities, timeoutConfiguration.Command));
- return new Browser(driver);
+ LocalizedLogger.Info("loc.browser.grid");
+ var capabilities = BrowserProfile.DriverSettings.DriverOptions.ToCapabilities();
+ try
+ {
+ return new RemoteWebDriver(BrowserProfile.RemoteConnectionUrl, capabilities, TimeoutConfiguration.Command);
+ }
+ catch (Exception e)
+ {
+ LocalizedLogger.Fatal("loc.browser.grid.fail", e);
+ throw;
+ }
}
}
}
diff --git a/Aquality.Selenium/src/Aquality.Selenium/Configurations/WebDriverSettings/DriverSettings.cs b/Aquality.Selenium/src/Aquality.Selenium/Configurations/WebDriverSettings/DriverSettings.cs
index 67c34f7d..fd5c8c73 100644
--- a/Aquality.Selenium/src/Aquality.Selenium/Configurations/WebDriverSettings/DriverSettings.cs
+++ b/Aquality.Selenium/src/Aquality.Selenium/Configurations/WebDriverSettings/DriverSettings.cs
@@ -15,6 +15,10 @@ namespace Aquality.Selenium.Configurations.WebDriverSettings
///
public abstract class DriverSettings : IDriverSettings
{
+ private IReadOnlyDictionary options;
+ private IReadOnlyDictionary capabilities;
+ private IReadOnlyList startArguments;
+
///
/// Instantiates class using JSON file with general settings.
///
@@ -50,11 +54,58 @@ public virtual string DownloadDir
public abstract string DownloadDirCapabilityKey { get; }
- protected IReadOnlyDictionary BrowserCapabilities => SettingsFile.GetValueDictionaryOrEmpty