From 5e5154535dd066c3e1efa8afba01d98ebf1db03a Mon Sep 17 00:00:00 2001 From: Pavel Anihimovsky <47742067+pavelanihimovsky@users.noreply.github.com> Date: Tue, 14 Apr 2020 17:23:26 +0300 Subject: [PATCH] Wrap ExecuteScript with ActionsRetrier (#175) --- .../Aquality.Selenium/Elements/Actions/JsActions.cs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/Aquality.Selenium/src/Aquality.Selenium/Elements/Actions/JsActions.cs b/Aquality.Selenium/src/Aquality.Selenium/Elements/Actions/JsActions.cs index 4a0914cc..1542ab16 100644 --- a/Aquality.Selenium/src/Aquality.Selenium/Elements/Actions/JsActions.cs +++ b/Aquality.Selenium/src/Aquality.Selenium/Elements/Actions/JsActions.cs @@ -6,6 +6,7 @@ using Aquality.Selenium.Browsers; using Aquality.Selenium.Configurations; using Aquality.Selenium.Core.Localization; +using Aquality.Selenium.Core.Utilities; using Aquality.Selenium.Elements.Interfaces; namespace Aquality.Selenium.Elements.Actions @@ -29,6 +30,8 @@ public JsActions(IElement element, string elementType, ILocalizedLogger logger, private Browser Browser => AqualityServices.Browser; + private IElementActionRetrier ActionRetrier => AqualityServices.Get(); + protected ILocalizedLogger Logger { get; } /// @@ -157,18 +160,20 @@ public string GetXPath() /// Point object. public Point GetViewPortCoordinates() { - var coordinates = ExecuteScript>(JavaScript.GetViewPortCoordinates).Select(item => double.Parse(item.ToString())).ToArray(); + var coordinates = ExecuteScript>(JavaScript.GetViewPortCoordinates) + .Select(item => double.Parse(item.ToString())) + .ToArray(); return new Point((int)Math.Round(coordinates[0]), (int)Math.Round(coordinates[1])); } protected T ExecuteScript(JavaScript scriptName, params object[] arguments) { - return Browser.ExecuteScript(scriptName, ResolveArguments(arguments)); + return ActionRetrier.DoWithRetry(() => Browser.ExecuteScript(scriptName, ResolveArguments(arguments))); } protected void ExecuteScript(JavaScript scriptName, params object[] arguments) { - Browser.ExecuteScript(scriptName, ResolveArguments(arguments)); + ActionRetrier.DoWithRetry(() => Browser.ExecuteScript(scriptName, ResolveArguments(arguments))); } protected internal void LogElementAction(string messageKey, params object[] args)