diff --git a/Aquality.Selenium/src/Aquality.Selenium/Elements/Actions/JsActions.cs b/Aquality.Selenium/src/Aquality.Selenium/Elements/Actions/JsActions.cs
index 0a9f9db3..1f8f18d6 100644
--- a/Aquality.Selenium/src/Aquality.Selenium/Elements/Actions/JsActions.cs
+++ b/Aquality.Selenium/src/Aquality.Selenium/Elements/Actions/JsActions.cs
@@ -1,4 +1,5 @@
using System;
+using System.Collections;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
@@ -72,8 +73,9 @@ public void ScrollIntoView()
///
/// Scrolling element by coordinates.
///
+ /// Element have to contains inner scroll bar.
/// Horizontal coordinate
- /// Verticale coordinate
+ /// Vertical coordinate
public void ScrollBy(int x, int y)
{
LogElementAction("loc.scrolling.js");
@@ -82,6 +84,7 @@ public void ScrollBy(int x, int y)
///
/// Scrolling to the center of element.
+ /// Upper bound of element will be in the center of the page after scrolling
///
public void ScrollToTheCenter()
{
@@ -159,17 +162,24 @@ public Point GetViewPortCoordinates()
protected T ExecuteScript(JavaScript scriptName, params object[] arguments)
{
- return Browser.ExecuteScript(scriptName, element.GetElement(), arguments);
+ return Browser.ExecuteScript(scriptName, ResolveArguments(arguments));
}
protected void ExecuteScript(JavaScript scriptName, params object[] arguments)
{
- Browser.ExecuteScript(scriptName, element.GetElement(), arguments);
+ Browser.ExecuteScript(scriptName, ResolveArguments(arguments));
}
protected internal void LogElementAction(string messageKey, params object[] args)
{
Logger.InfoLocElementAction(elementType, element.Name, messageKey, args);
}
+
+ private object[] ResolveArguments(params object[] arguments)
+ {
+ var args = new ArrayList { element.GetElement() };
+ args.AddRange(arguments);
+ return args.ToArray();
+ }
}
}
diff --git a/Aquality.Selenium/tests/Aquality.Selenium.Tests/Aquality.Selenium.Tests.csproj b/Aquality.Selenium/tests/Aquality.Selenium.Tests/Aquality.Selenium.Tests.csproj
index 321470cf..161bb442 100644
--- a/Aquality.Selenium/tests/Aquality.Selenium.Tests/Aquality.Selenium.Tests.csproj
+++ b/Aquality.Selenium/tests/Aquality.Selenium.Tests/Aquality.Selenium.Tests.csproj
@@ -8,13 +8,19 @@
+
+
+
+
+
+
diff --git a/Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/Actions/JsActionsTests.cs b/Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/Actions/JsActionsTests.cs
index 8356e127..59cfb31f 100644
--- a/Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/Actions/JsActionsTests.cs
+++ b/Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/Actions/JsActionsTests.cs
@@ -1,3 +1,7 @@
+using System;
+using System.Collections.Generic;
+using System.Drawing;
+using System.Linq;
using Aquality.Selenium.Browsers;
using Aquality.Selenium.Elements;
using Aquality.Selenium.Tests.Integration.TestApp;
@@ -22,7 +26,7 @@ public void Should_BePossibleTo_Click()
[Test]
public void Should_BePossibleTo_ClickAndWait()
- {
+ {
var welcomeForm = new WelcomeForm();
welcomeForm.Open();
welcomeForm.GetExampleLink(AvailableExample.Dropdown).JsActions.ClickAndWait();
@@ -75,7 +79,7 @@ public void Should_BePossibleTo_CheckIsElementOnScreen()
hoversForm.Open();
Assert.Multiple(() =>
{
- Assert.IsFalse(hoversForm.GetHiddenElement(HoverExample.First, ElementState.ExistsInAnyState).JsActions.IsElementOnScreen(),
+ Assert.IsFalse(hoversForm.GetHiddenElement(HoverExample.First, ElementState.ExistsInAnyState).JsActions.IsElementOnScreen(),
$"Hidden element for {HoverExample.First} should be invisible.");
Assert.IsTrue(hoversForm.GetExample(HoverExample.First).JsActions.IsElementOnScreen(),
$"Element for {HoverExample.First} should be visible.");
@@ -87,7 +91,7 @@ public void Should_BePossibleTo_SetValue()
{
var keyPressesForm = new KeyPressesForm();
keyPressesForm.Open();
- var text = "text";
+ const string text = "text";
keyPressesForm.InputTextBox.JsActions.SetValue(text);
var actualText = keyPressesForm.InputTextBox.Value;
Assert.AreEqual(text, actualText, $"Text should be '{text}' after setting value via JS");
@@ -108,7 +112,7 @@ public void Should_BePossibleTo_GetXPathLocator()
var welcomeForm = new WelcomeForm();
welcomeForm.Open();
var actualLocator = welcomeForm.SubTitleLabel.JsActions.GetXPath();
- var expectedLocator = "/html/body/DIV[2]/DIV[1]/H2[1]";
+ const string expectedLocator = "/html/body/DIV[2]/DIV[1]/H2[1]";
Assert.AreEqual(expectedLocator, actualLocator, $"Locator of sub title should be {expectedLocator}");
}
@@ -126,48 +130,59 @@ public void Should_BePossibleTo_ScrollIntoView()
{
var infiniteScrollForm = new InfiniteScrollForm();
infiniteScrollForm.Open();
+ infiniteScrollForm.WaitForPageToLoad();
var defaultCount = infiniteScrollForm.ExampleLabels.Count;
- infiniteScrollForm.LastExampleLabel.JsActions.ScrollIntoView();
Assert.DoesNotThrow(
() => ConditionalWait.WaitForTrue(() =>
{
infiniteScrollForm.LastExampleLabel.JsActions.ScrollIntoView();
return infiniteScrollForm.ExampleLabels.Count > defaultCount;
- }),
- "Some examples should be added after scroll");
+ }), "Some examples should be added after scroll");
}
- [Ignore("Need to fix on Azure")]
[Test]
public void Should_BePossibleTo_ScrollBy()
{
- var infiniteScrollForm = new InfiniteScrollForm();
- infiniteScrollForm.Open();
- var defaultCount = infiniteScrollForm.ExampleLabels.Count;
- Assert.DoesNotThrow(
- () => ConditionalWait.WaitForTrue(() =>
- {
- infiniteScrollForm.LastExampleLabel.JsActions.ScrollBy(100000, 100000);
- return infiniteScrollForm.ExampleLabels.Count > defaultCount;
- }),
- "Some examples should be added after scroll");
+ var point = new Point(50, 40);
+ var homeDemoSiteForm = new HomeDemoSiteForm();
+ homeDemoSiteForm.Open();
+ homeDemoSiteForm.FirstScrollableExample.JsActions.ScrollBy(point.X, point.Y);
+ var currentCoordinates = BrowserManager.Browser
+ .ExecuteScriptFromFile>("Resources.GetScrollCoordinates.js",
+ homeDemoSiteForm.FirstScrollableExample.GetElement()).Select(item => int.Parse(item.ToString()))
+ .ToList();
+ var actualPoint = new Point(currentCoordinates[0], currentCoordinates[1]);
+ Assert.AreEqual(point, actualPoint, $"Current coordinates should be '{point}'");
}
- [Ignore("Need to fix on Azure")]
[Test]
public void Should_BePossibleTo_ScrollToTheCenter()
+ {
+ const int accuracy = 1;
+ var welcomeForm = new WelcomeForm();
+ welcomeForm.Open();
+ welcomeForm.GetExampleLink(AvailableExample.Dropdown).JsActions.ScrollToTheCenter();
+
+ var windowSize = BrowserManager.Browser.ExecuteScriptFromFile