diff --git a/Aquality.Selenium/src/Aquality.Selenium/Aquality.Selenium.xml b/Aquality.Selenium/src/Aquality.Selenium/Aquality.Selenium.xml
index a60beb64..a88e4541 100644
--- a/Aquality.Selenium/src/Aquality.Selenium/Aquality.Selenium.xml
+++ b/Aquality.Selenium/src/Aquality.Selenium/Aquality.Selenium.xml
@@ -230,6 +230,21 @@
Horizontal coordinate.
Vertical coordinate.
+
+
+ Scrolls window by coordinates using JavaScript.
+
+ Horizontal coordinate.
+ Vertical coordinate.
+
+
+
+ Scrolls portion of screen from specified origin
+
+ Origination point (either viewport or element, with possible offset).
+ Horizontal coordinate.
+ Vertical coordinate.
+
Executes JS script from embedded resource file (*.js).
@@ -1452,6 +1467,16 @@
Perfroms right click on element.
+
+
+ Scrolling page to the element.
+
+
+
+
+ Scrolling page from an element.
+
+
Moves mouse to the element.
@@ -2424,6 +2449,13 @@
horizontal coordinate
vertical coordinate
+
+
+ Scroll form via JavaScript without scrolling entire page
+
+ horizontal coordinate
+ vertical coordinate
+
DevTools Command/Result logging options.
diff --git a/Aquality.Selenium/src/Aquality.Selenium/Browsers/Browser.cs b/Aquality.Selenium/src/Aquality.Selenium/Browsers/Browser.cs
index 02fa0afc..d9bb0da3 100644
--- a/Aquality.Selenium/src/Aquality.Selenium/Browsers/Browser.cs
+++ b/Aquality.Selenium/src/Aquality.Selenium/Browsers/Browser.cs
@@ -10,6 +10,8 @@
using System.Collections.ObjectModel;
using IDevTools = OpenQA.Selenium.DevTools.IDevTools;
+using OpenQA.Selenium.Interactions;
+using static OpenQA.Selenium.Interactions.WheelInputDevice;
namespace Aquality.Selenium.Browsers
{
@@ -319,9 +321,32 @@ public ReadOnlyCollection GetLogs(string logKind)
/// Vertical coordinate.
public void ScrollWindowBy(int x, int y)
{
+ Logger.Info("loc.scrolling.by", x, y);
+ new Actions(Driver).ScrollByAmount(x, y).Perform();
+ }
+
+ ///
+ /// Scrolls window by coordinates using JavaScript.
+ ///
+ /// Horizontal coordinate.
+ /// Vertical coordinate.
+ public void ScrollWindowByViaJs(int x, int y)
+ {
+ Logger.Info("loc.scrolling.by.js", x, y);
ExecuteScript(JavaScript.ScrollWindowBy, x, y);
}
+ ///
+ /// Scrolls portion of screen from specified origin
+ ///
+ /// Origination point (either viewport or element, with possible offset).
+ /// Horizontal coordinate.
+ /// Vertical coordinate.
+ public void ScrollFromOrigin(ScrollOrigin scrollOrigin, int x, int y)
+ {
+ new Actions(Driver).ScrollFromOrigin(scrollOrigin, x, y).Perform();
+ }
+
///
/// Executes JS script from embedded resource file (*.js).
///
diff --git a/Aquality.Selenium/src/Aquality.Selenium/Elements/Actions/JsActions.cs b/Aquality.Selenium/src/Aquality.Selenium/Elements/Actions/JsActions.cs
index d5988627..9692942c 100644
--- a/Aquality.Selenium/src/Aquality.Selenium/Elements/Actions/JsActions.cs
+++ b/Aquality.Selenium/src/Aquality.Selenium/Elements/Actions/JsActions.cs
@@ -93,7 +93,7 @@ public void ScrollIntoView()
/// Vertical coordinate
public void ScrollBy(int x, int y)
{
- LogElementAction("loc.scrolling.js");
+ LogElementAction("loc.scrolling.by.js", x, y);
ExecuteScript(JavaScript.ScrollBy, x, y);
}
diff --git a/Aquality.Selenium/src/Aquality.Selenium/Elements/Actions/MouseActions.cs b/Aquality.Selenium/src/Aquality.Selenium/Elements/Actions/MouseActions.cs
index c1a0e96c..3dd9415a 100644
--- a/Aquality.Selenium/src/Aquality.Selenium/Elements/Actions/MouseActions.cs
+++ b/Aquality.Selenium/src/Aquality.Selenium/Elements/Actions/MouseActions.cs
@@ -6,6 +6,7 @@
using Aquality.Selenium.Core.Utilities;
using Aquality.Selenium.Core.Localization;
using Aquality.Selenium.Configurations;
+using static OpenQA.Selenium.Interactions.WheelInputDevice;
namespace Aquality.Selenium.Elements.Actions
{
@@ -57,6 +58,39 @@ public void RightClick()
elementActionsRetrier.DoWithRetry(() => PerformAction(element => MoveToElement(element).ContextClick(element)));
}
+ ///
+ /// Scrolling page to the element.
+ ///
+ public void ScrollToElement()
+ {
+ LogElementAction("loc.scrolling");
+ elementActionsRetrier.DoWithRetry(() => PerformAction(element => new SeleniumActions(AqualityServices.Browser.Driver).ScrollToElement(element)));
+ }
+
+ ///
+ /// Scrolling page from an element.
+ ///
+ public void ScrollFromOrigin(int x, int y, int? xOffset = null, int? yOffset = null)
+ {
+ LogElementAction("loc.scrolling.by", x, y);
+ elementActionsRetrier.DoWithRetry(() =>
+ {
+ var scrollOrigin = new ScrollOrigin
+ {
+ Element = element.GetElement()
+ };
+ if (xOffset != null)
+ {
+ scrollOrigin.XOffset = xOffset.Value;
+ }
+ if (yOffset != null)
+ {
+ scrollOrigin.YOffset = yOffset.Value;
+ }
+ AqualityServices.Browser.ScrollFromOrigin(scrollOrigin, x, y);
+ });
+ }
+
///
/// Moves mouse to the element.
///
diff --git a/Aquality.Selenium/src/Aquality.Selenium/Forms/Form.cs b/Aquality.Selenium/src/Aquality.Selenium/Forms/Form.cs
index 0120ce80..96302311 100644
--- a/Aquality.Selenium/src/Aquality.Selenium/Forms/Form.cs
+++ b/Aquality.Selenium/src/Aquality.Selenium/Forms/Form.cs
@@ -86,6 +86,16 @@ protected Form(By locator, string name)
/// horizontal coordinate
/// vertical coordinate
public void ScrollBy(int x, int y)
+ {
+ FormElement.MouseActions.ScrollFromOrigin(x, y);
+ }
+
+ ///
+ /// Scroll form via JavaScript without scrolling entire page
+ ///
+ /// horizontal coordinate
+ /// vertical coordinate
+ public void ScrollByJs(int x, int y)
{
FormElement.JsActions.ScrollBy(x, y);
}
diff --git a/Aquality.Selenium/src/Aquality.Selenium/Resources/Localization/be.json b/Aquality.Selenium/src/Aquality.Selenium/Resources/Localization/be.json
index 90669f5d..f7ba8b6a 100644
--- a/Aquality.Selenium/src/Aquality.Selenium/Resources/Localization/be.json
+++ b/Aquality.Selenium/src/Aquality.Selenium/Resources/Localization/be.json
@@ -66,7 +66,10 @@
"loc.movingFrom": "Адводзім курсор мышы ад элемента",
"loc.radio": "Радыёкнопка",
"loc.scrolling.center.js": "Пракручваем старонку да цэнтра элемента праз JavaScript",
- "loc.scrolling.js": "Пракручваем старонку праз JavaScript",
+ "loc.scrolling.js": "Пракручваем старонку да элемента праз JavaScript",
+ "loc.scrolling": "Пракручваем старонку да элемента",
+ "loc.scrolling.by": "Пракручваем на ({0},{1})",
+ "loc.scrolling.by.js": "Пракручваем на ({0},{1}) праз JavaScript",
"loc.selecting.value": "Выбіраем значэнне - '{0}'",
"loc.deselecting.value": "Адмяняем выбар значэння - '{0}'",
"loc.send.text": "Задаем тэкст - '{0}'",
diff --git a/Aquality.Selenium/src/Aquality.Selenium/Resources/Localization/en.json b/Aquality.Selenium/src/Aquality.Selenium/Resources/Localization/en.json
index 03b54834..c2fd571a 100644
--- a/Aquality.Selenium/src/Aquality.Selenium/Resources/Localization/en.json
+++ b/Aquality.Selenium/src/Aquality.Selenium/Resources/Localization/en.json
@@ -66,7 +66,10 @@
"loc.movingFrom": "Moving mouse from element",
"loc.radio": "RadioButton",
"loc.scrolling.center.js": "Scrolling to the center via JavaScript",
- "loc.scrolling.js": "Scrolling via JavaScript",
+ "loc.scrolling.js": "Scrolling to element via JavaScript",
+ "loc.scrolling": "Scrolling to element",
+ "loc.scrolling.by": "Scrolling by ({0},{1})",
+ "loc.scrolling.by.js": "Scrolling by ({0},{1}) via JavaScript",
"loc.selecting.value": "Selecting value - '{0}'",
"loc.deselecting.value": "Deselecting value - '{0}'",
"loc.send.text": "Setting text - '{0}'",
diff --git a/Aquality.Selenium/src/Aquality.Selenium/Resources/Localization/pl.json b/Aquality.Selenium/src/Aquality.Selenium/Resources/Localization/pl.json
index 9f383360..163c3986 100644
--- a/Aquality.Selenium/src/Aquality.Selenium/Resources/Localization/pl.json
+++ b/Aquality.Selenium/src/Aquality.Selenium/Resources/Localization/pl.json
@@ -66,7 +66,10 @@
"loc.movingFrom": "Przesuwanie myszy z elementu",
"loc.radio": "RadioButton",
"loc.scrolling.center.js": "Przewijanie do centrum przez JavaScript",
- "loc.scrolling.js": "Przewijanie przez JavaScript",
+ "loc.scrolling.js": "Przewijanie do elementu przez JavaScript",
+ "loc.scrolling": "Przewijanie do elementu",
+ "loc.scrolling.by": "Przewijanie o ({0},{1})",
+ "loc.scrolling.by.js": "Przewijanie o ({0},{1}) przez JavaScript",
"loc.selecting.value": "Wybieranie wartości - '{0}'",
"loc.deselecting.value": "Anulowanie wybierania wartości - '{0}'",
"loc.send.text": "Ustawianie tekstu - '{0}'",
diff --git a/Aquality.Selenium/src/Aquality.Selenium/Resources/Localization/ru.json b/Aquality.Selenium/src/Aquality.Selenium/Resources/Localization/ru.json
index dd35bcf4..c3c7d0ed 100644
--- a/Aquality.Selenium/src/Aquality.Selenium/Resources/Localization/ru.json
+++ b/Aquality.Selenium/src/Aquality.Selenium/Resources/Localization/ru.json
@@ -66,7 +66,10 @@
"loc.movingFrom": "Сдвиг курсора с элемента",
"loc.radio": "Радиокнопка",
"loc.scrolling.center.js": "Скроллинг в центр посредством JavaScript",
- "loc.scrolling.js": "Скроллинг с помощью JavaScript",
+ "loc.scrolling.js": "Скроллинг к элементу с помощью JavaScript",
+ "loc.scrolling": "Скроллинг к элементу",
+ "loc.scrolling.by": "Скроллинг на ({0},{1})",
+ "loc.scrolling.by.js": "Скроллинг на ({0},{1}) с помощью JavaScript",
"loc.selecting.value": "Выбор значения - '{0}'",
"loc.deselecting.value": "Отмена выбора значения - '{0}'",
"loc.send.text": "Ввод текста - '{0}'",
diff --git a/Aquality.Selenium/src/Aquality.Selenium/Resources/Localization/uk.json b/Aquality.Selenium/src/Aquality.Selenium/Resources/Localization/uk.json
index d3850c95..3e4636be 100644
--- a/Aquality.Selenium/src/Aquality.Selenium/Resources/Localization/uk.json
+++ b/Aquality.Selenium/src/Aquality.Selenium/Resources/Localization/uk.json
@@ -66,7 +66,10 @@
"loc.movingFrom": "Переміщення миші від елемента",
"loc.radio": "Радіокнопка",
"loc.scrolling.center.js": "Прокрутка до центру за допомогою JavaScript",
- "loc.scrolling.js": "Прокрутка за допомогою JavaScript",
+ "loc.scrolling.js": "Прокрутка до елемента за допомогою JavaScript",
+ "loc.scrolling": "Прокрутка до елемента",
+ "loc.scrolling.by": "Прокрутка на ({0},{1})",
+ "loc.scrolling.by.js": "Прокрутка на ({0},{1}) за допомогою JavaScript",
"loc.selecting.value": "Вибір значення - '{0}'",
"loc.deselecting.value": "Скасування выбору значення - '{0}'",
"loc.send.text": "Встановлення тексту - '{0}'",
diff --git a/Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/Actions/MouseActionsTests.cs b/Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/Actions/MouseActionsTests.cs
index 2bd2736b..bd6ab983 100644
--- a/Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/Actions/MouseActionsTests.cs
+++ b/Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/Actions/MouseActionsTests.cs
@@ -42,5 +42,38 @@ public void Should_BePossibleTo_MoveToElement()
JQueryMenuForm.EnabledButton.MouseActions.MoveToElement();
Assert.That(JQueryMenuForm.IsEnabledButtonFocused, "Element should be focused after move mouse");
}
+
+ [Test]
+ public void Should_BePossibleTo_ScrollToElement()
+ {
+ var infiniteScrollForm = new InfiniteScrollForm();
+ infiniteScrollForm.Open();
+ infiniteScrollForm.WaitForPageToLoad();
+ var size = infiniteScrollForm.LastExampleLabel.Visual.Size;
+ AqualityServices.Browser.SetWindowSize(size.Width, size.Height);
+ var defaultCount = infiniteScrollForm.ExampleLabels.Count;
+ Assert.DoesNotThrow(
+ () => AqualityServices.ConditionalWait.WaitForTrue(() =>
+ {
+ infiniteScrollForm.LastExampleLabel.MouseActions.ScrollToElement();
+ return infiniteScrollForm.ExampleLabels.Count > defaultCount;
+ }), "Some examples should be added after scroll");
+ }
+
+ [Test]
+ public void Should_BePossibleTo_ScrollFromOrigin()
+ {
+ var infiniteScrollForm = new InfiniteScrollForm();
+ infiniteScrollForm.Open();
+ infiniteScrollForm.WaitForPageToLoad();
+ var defaultCount = infiniteScrollForm.ExampleLabels.Count;
+ Assert.DoesNotThrow(
+ () => AqualityServices.ConditionalWait.WaitForTrue(() =>
+ {
+ var formHeight = infiniteScrollForm.Size.Height;
+ infiniteScrollForm.LastExampleLabel.MouseActions.ScrollFromOrigin(0, formHeight);
+ return infiniteScrollForm.ExampleLabels.Count > defaultCount;
+ }), "Some examples should be added after scroll");
+ }
}
}
diff --git a/Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/BrowserTests.cs b/Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/BrowserTests.cs
index 5b9bc6f8..0e11466f 100644
--- a/Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/BrowserTests.cs
+++ b/Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/BrowserTests.cs
@@ -200,6 +200,22 @@ public void Should_BePossibleTo_ScrollWindowBy()
}), "Some examples should be added after scroll");
}
+ [Test]
+ public void Should_BePossibleTo_ScrollWindowBy_ViaJs()
+ {
+ var infiniteScrollForm = new InfiniteScrollForm();
+ infiniteScrollForm.Open();
+ infiniteScrollForm.WaitForPageToLoad();
+ var defaultCount = infiniteScrollForm.ExampleLabels.Count;
+ Assert.DoesNotThrow(
+ () => AqualityServices.ConditionalWait.WaitForTrue(() =>
+ {
+ var formHeight = infiniteScrollForm.Size.Height;
+ AqualityServices.Browser.ScrollWindowByViaJs(0, formHeight);
+ return infiniteScrollForm.ExampleLabels.Count > defaultCount;
+ }), "Some examples should be added after scroll");
+ }
+
[Test]
public void Should_BePossibleTo_GetBrowserName()
{