Skip to content

Commit

Permalink
#542 New TypesTextUsingFocusBehaviorAndSendKeysAttribute
Browse files Browse the repository at this point in the history
  • Loading branch information
YevgeniyShunevych committed Sep 8, 2021
1 parent 3e63b09 commit 74ed2fa
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
using OpenQA.Selenium;

namespace Atata
{
/// <summary>
/// Represents the behavior for control text typing by executing <see cref="FocusBehaviorAttribute"/> behavior
/// and then invoking <see cref="IWebElement.SendKeys(string)"/> method.
/// </summary>
public class TypesTextUsingFocusBehaviorAndSendKeysAttribute : TypesTextUsingSendKeysAttribute
{
/// <inheritdoc/>
public override void Execute<TOwner>(IUIComponent<TOwner> component, string value)
{
if (!string.IsNullOrEmpty(value))
{
AtataContext.Current.UIComponentScopeCache.ExecuteWithin(() =>
{
component.ExecuteBehavior<FocusBehaviorAttribute>(x => x.Execute(component));

base.Execute(component, value);
});
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ public class TextTypeBehaviorAttributeTests : UITestFixture
new[]
{
new TestCaseData(new TypesTextUsingSendKeysAttribute()).Returns(ConcatValue),
new TestCaseData(new TypesTextUsingFocusBehaviorAndSendKeysAttribute()).Returns(ConcatValue),
new TestCaseData(new TypesTextUsingScriptAttribute()).Returns(ConcatValue),
new TestCaseData(new TypesTextUsingSendKeysCharByCharAttribute()).Returns(ConcatValue),
new TestCaseData(new TypesTextUsingFocusBehaviorAndSendKeysCharByCharAttribute()).Returns(ConcatValue)
Expand Down

0 comments on commit 74ed2fa

Please sign in to comment.