Skip to content

Instantly share code, notes, and snippets.

View YevgeniyShunevych's full-sized avatar

Yevgeniy Shunevych YevgeniyShunevych

View GitHub Profile
@YevgeniyShunevych
YevgeniyShunevych / Select`2.cs
Last active August 19, 2021 07:19
Select2<T, TOwner> control
namespace Atata
{
/// <summary>
/// Represents the "Select 2" dropdown control (class: "select2-container").
/// </summary>
/// <typeparam name="T">The type of the control's data.</typeparam>
/// <typeparam name="TOwner">The type of the owner.</typeparam>
[ControlDefinition(ContainingClass = "select2-container", ComponentTypeName = "select")]
public class Select2<T, TOwner> : EditableField<T, TOwner>
where TOwner : PageObject<TOwner>
@YevgeniyShunevych
YevgeniyShunevych / MatRadioButton`1.cs
Created March 24, 2020 13:32
Atata component for Angular Material radio button
namespace Atata.Angular.Material
{
[ControlDefinition("input[@type='radio']", ContainingClass = "mat-radio-input", ComponentTypeName = "radio button", Visibility = Visibility.Any, IgnoreNameEndings = "RadioButton,Radio,Button,Option")]
[TermFindSettings(TargetAttributeType = typeof(FindByLabelAttribute), Format = "\u00A0{0}")]
public class MatRadioButton<TOwner> : RadioButton<TOwner>
where TOwner : PageObject<TOwner>
{
[FindFirst(OuterXPath = "ancestor::")]
[TraceLog]
public Label<TOwner> WrapperLabel { get; private set; }
@YevgeniyShunevych
YevgeniyShunevych / SecurePasswordInput`1.cs
Last active March 18, 2020 12:39
Atata secure password input. Works the same way as a regular PasswordInput<TOwner> but in log hides the password value during setting replacing it with *****.
namespace Atata
{
[ControlDefinition("input[@type='password']", ComponentTypeName = "password input")]
[ValueGetFormat("{0}")]
[ValueSetFormat("{0}")]
public class SecurePasswordInput<TOwner> : Input<string, TOwner>
where TOwner : PageObject<TOwner>
{
protected override string ConvertValueToString(string value)
{
@YevgeniyShunevych
YevgeniyShunevych / MDOption`2.cs
Created February 11, 2020 14:18
Atata component for AngularJS Material Select
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()
@YevgeniyShunevych
YevgeniyShunevych / EditableFieldExtensions.cs
Created January 14, 2020 10:46
SetAndAssert Atata extension method.
namespace Atata
{
public static class EditableFieldExtensions
{
public static TOwner SetAndAssert<T, TOwner>(this EditableField<T, TOwner> editableField, T value)
where TOwner : PageObject<TOwner>
{
editableField.Set(value);
return editableField.Should.Equal(value);
@YevgeniyShunevych
YevgeniyShunevych / FindInShadowDomAttribute.cs
Last active October 31, 2019 14:34
Atata - FindInShadowDomAttribute
using System;
using System.Collections.Generic;
namespace Atata
{
public class FindInShadowDomAttribute : FindAttribute
{
public FindInShadowDomAttribute(params string[] shadowContainerXPaths)
{
ShadowContainerXPaths = shadowContainerXPaths;
@YevgeniyShunevych
YevgeniyShunevych / WaitAndSwitchToNextWindowAttribute.cs
Last active September 25, 2019 15:01
WaitAndSwitchToNextWindowAttribute trigger
using System.Linq;
namespace Atata
{
public class WaitAndSwitchToNextWindowAttribute : TriggerAttribute
{
public WaitAndSwitchToNextWindowAttribute(TriggerEvents on = TriggerEvents.AfterClick, TriggerPriority priority = TriggerPriority.Medium)
: base(on, priority)
{
}
@YevgeniyShunevych
YevgeniyShunevych / SamplePage.cs
Created July 2, 2019 12:18
How to get Atata control by attribute using variable
using Atata;
namespace SomeApp.UITests
{
using _ = SamplePage;
public class SamplePage : Page<_>
{
public Control<_> GetSomeControl(string attributeValue)
{
@YevgeniyShunevych
YevgeniyShunevych / SamplePage.cs
Created March 18, 2019 10:54
How to get Atata control using variable
using Atata;
namespace SomeApp.UITests
{
using _ = SamplePage;
public class SamplePage : Page<_>
{
public Control<_> GetSomeSpecificControl(string text)
{
@YevgeniyShunevych
YevgeniyShunevych / FindByPrecedingSpanAttribute.cs
Last active March 18, 2019 10:39
Custom Atata FindByXPathAttribute
namespace Atata
{
public class FindByPrecedingSpanAttribute : FindByXPathAttribute
{
public FindByPrecedingSpanAttribute(params string[] terms)
: this(TermMatch.Equals, terms)
{
}
public FindByPrecedingSpanAttribute(TermMatch match, params string[] terms)