-
-
Notifications
You must be signed in to change notification settings - Fork 82
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#79 Add ScrollTo method to Control`1
- Loading branch information
1 parent
072fbe5
commit 7d13c0b
Showing
7 changed files
with
96 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
namespace Atata | ||
{ | ||
/// <summary> | ||
/// Represents the base behavior class for scrolling to control. | ||
/// </summary> | ||
public abstract class ScrollBehaviorAttribute : MulticastAttribute | ||
{ | ||
public abstract void Execute<TOwner>(IControl<TOwner> control) | ||
where TOwner : PageObject<TOwner>, IPageObject<TOwner>; | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
src/Atata/Attributes/Behaviors/ScrollUsingMoveToElementAttribute.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
using OpenQA.Selenium; | ||
using OpenQA.Selenium.Interactions; | ||
|
||
namespace Atata | ||
{ | ||
/// <summary> | ||
/// Represents the behavior for scrolling to control using WebDriver's <see cref="Actions"/>. | ||
/// Performs <see cref="Actions.MoveToElement(IWebElement)"/> action. | ||
/// </summary> | ||
public class ScrollUsingMoveToElementAttribute : ScrollBehaviorAttribute | ||
{ | ||
public override void Execute<TOwner>(IControl<TOwner> control) | ||
{ | ||
control.Owner.Driver.Perform(a => a.MoveToElement(control.Scope)); | ||
} | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
src/Atata/Attributes/Behaviors/ScrollUsingScrollIntoViewAttribute.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
namespace Atata | ||
{ | ||
/// <summary> | ||
/// Represents the behavior for scrolling to control using JavaScript. | ||
/// Performs "element.scrollIntoView(true)" function. | ||
/// </summary> | ||
public class ScrollUsingScrollIntoViewAttribute : ScrollBehaviorAttribute | ||
{ | ||
public override void Execute<TOwner>(IControl<TOwner> control) | ||
{ | ||
control.Owner.Driver.ExecuteScript("arguments[0].scrollIntoView(true);", control.Scope); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
namespace Atata | ||
{ | ||
public class ScrollToComponentLogSection : UIComponentLogSection | ||
{ | ||
public ScrollToComponentLogSection(UIComponent component) | ||
: base(component) | ||
{ | ||
Message = $"Scroll to {component.ComponentFullName}"; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters