Skip to content

Commit 2a15c4f

Browse files
authored
Merge pull request #45 from aquality-automation/feature/10-implement-base-class-for-Form
Feature/10 implement base class for form
2 parents dcce638 + 35f1fec commit 2a15c4f

File tree

1 file changed

+58
-3
lines changed
  • Aquality.Selenium/src/Aquality.Selenium/Forms

1 file changed

+58
-3
lines changed
Lines changed: 58 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,65 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using System.Text;
1+
using Aquality.Selenium.Elements;
2+
using Aquality.Selenium.Elements.Interfaces;
3+
using OpenQA.Selenium;
4+
using Aquality.Selenium.Logging;
45

56
namespace Aquality.Selenium.Forms
67
{
8+
/// <summary>
9+
/// Defines base class for any UI form.
10+
/// </summary>
711
public abstract class Form
812
{
13+
/// <summary>
14+
/// Instance of logger <see cref="Aquality.Selenium.Logging.Logger">
15+
/// </summary>
16+
/// <value>Logger instance.</value>
17+
protected Logger Logger => Logger.Instance;
18+
19+
/// <summary>
20+
/// Locator for specified form
21+
/// </summary>
22+
protected readonly By Locator;
23+
24+
/// <summary>
25+
/// Name of specified form
26+
/// </summary>
27+
protected readonly string Name;
28+
29+
/// <summary>
30+
/// Element factory <see cref="Aquality.Selenium.Elements.Interfaces.IElementFactory">
31+
/// </summary>
32+
/// <value>Element factory.</value>
33+
protected IElementFactory ElementFactory => new ElementFactory();
34+
35+
private ILabel FormLabel => ElementFactory.GetLabel(Locator, Name);
36+
37+
/// <summary>
38+
/// Return form state for form locator
39+
/// </summary>
40+
/// <value>True - form is opened,
41+
/// False - form is not opened.</value>
42+
public bool IsDisplayed => FormLabel.State.WaitForDisplayed();
43+
44+
/// <summary>
45+
/// Constructor with parameters
46+
/// </summary>
47+
/// <param name="locator">Unique locator of the form.</param>
48+
/// <param name="name">Name of the form.</param>
49+
protected Form(By locator, string name)
50+
{
51+
Locator = locator;
52+
Name = name;
53+
}
54+
55+
/// <summary>
56+
/// Scroll form without scrolling entire page
57+
/// </summary>
58+
/// <param name="x">horizontal coordinate</param>
59+
/// <param name="y">vertical coordinate</param>
60+
public void ScrollBy(int x, int y)
61+
{
62+
FormLabel.JsActions.ScrollBy(x, y);
63+
}
964
}
1065
}

0 commit comments

Comments
 (0)