Created
February 11, 2020 14:18
-
-
Save YevgeniyShunevych/2732c2d989b4bf880d393eb9cd73e64f to your computer and use it in GitHub Desktop.
Atata component for AngularJS Material Select
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
namespace Atata.AngularJS.Material | |
{ | |
[ControlDefinition("md-option", ComponentTypeName = "option")] | |
public class MDOption<T, TOwner> : Field<T, TOwner> | |
where TOwner : PageObject<TOwner> | |
{ | |
[FindByClass("md-text")] | |
public Text<TOwner> Text { get; private set; } | |
protected override T GetValue() | |
{ | |
return ConvertStringToValueUsingGetFormat(Text.Value); | |
} | |
} | |
} |
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
namespace Atata.AngularJS.Material | |
{ | |
[ControlDefinition("md-select", ComponentTypeName = "select")] | |
[ControlFinding(FindTermBy.Label)] | |
public class MDSelect<T, TOwner> : EditableField<T, TOwner> | |
where TOwner : PageObject<TOwner> | |
{ | |
[ControlDefinition("div", ContainingClass = "md-select-menu-container", ComponentTypeName = "drop-down menu")] | |
[FindFirst(ScopeSource = ScopeSource.Page)] | |
public ItemsControl<MDOption<T, TOwner>, TOwner> Options { get; private set; } | |
[ControlDefinition("md-select-value", ComponentTypeName = "selected value text")] | |
protected Text<TOwner> SelectedValueText { get; private set; } | |
protected override T GetValue() | |
{ | |
string valueAsString = SelectedValueText.Value; | |
return ConvertStringToValueUsingGetFormat(valueAsString); | |
} | |
protected override void SetValue(T value) | |
{ | |
Click(); | |
string valueAsString = ConvertValueToStringUsingSetFormat(value); | |
var option = Options.Items.GetByXPathCondition(valueAsString, $"normalize-space(.) = '{valueAsString}'"); | |
option.Click(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment