I am pretty new to C# and Playwright (just started learning it). Coming from Cypress it's a little bit more low level....but one thing that confused me is their "Page Object" section.
All of it makes sense, but I don't understand what these "IVariables" are. Like IPage and ILocator. (From: https://playwright.dev/dotnet/docs/pom)
using System.Threading.Tasks;
using Microsoft.Playwright;
namespace BigEcommerceApp.Tests.Models;
public class SearchPage
{
private readonly IPage _page;
private readonly ILocator _searchTermInput;
public SearchPage(IPage page)
{
_page = page;
_searchTermInput = page.Locator("[aria-label='Enter your search term']");
}
public async Task GotoAsync()
{
await _page.GotoAsync("https://bing.com");
}
public async Task SearchAsync(string text)
{
await _searchTermInput.FillAsync(text);
await _searchTermInput.PressAsync("Enter");
}
}
Like obviously I understand they are an instance of these classes...but is "I" some sort of pre-fix for classes for C#? or is this just a general naming convention.
It appears that using I to prefix an Interface name is a naming convention for C# generally, and not specific to Playwright. So those are just specifying that the types are the interfaces for pages and locators.