4

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?

Dariusz Woźniak
  • 9,640
  • 6
  • 60
  • 73
Reuel Ribeiro
  • 1,419
  • 14
  • 23

1 Answers1

4

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.

Yevgeniy Shunevych
  • 1,136
  • 6
  • 11