Search code examples
c#seleniumui-automationatata

Which is the difference between Link and DelegateLink on Atata framework?


I could not figure out from the documentation the difference between Link and LinkDelegate components.

https://atata-framework.github.io/components/#link

Could someone explain on which scenarios would you use each one?


Solution

  • The main difference is a usage syntax.

    using _ = SamplePage;
    
    public class SamplePage : Page<SamplePage>
    {
        public Link<_> Save1 { get; private set; }
    
        public LinkDelegate<_> Save2 { get; private set; }
    
        public Link<SamplePage2, _> Navigate1 { get; private set; }
    
        public LinkDelegate<SamplePage2, _> Navigate2 { get; private set; }
    }
    

    For internal links, without navigation:

    Go.To<SamplePage>().
        // To click:
        Save1.Click().
        Save2(). // As it delegate, use it like a method. Provides shorter syntax.
        // To verify:
        Save1.Should.Exist().
        Save2.Should().Exist(); // Should() is extension method.
    

    For navigation links:

    Go.To<SamplePage>().
        Navigate1.ClickAndGo();
    
    Go.To<SamplePage>().
        Navigate2(); // Shorter syntax.
    

    The same applies to Button and ButtonDelegate.

    So, if you often need to call a link/button, and don't verify it's state, you can use delegate option, to keep short call syntax.