Yapoml Documentation

website·Indexed 31 days ago

https://yapoml.dev

A tool for fast, expressive UI test authoring that generates C# page object classes on the fly from a concise YAML syntax. It supports integration with Microsoft Playwright and Selenium WebDriver, providing fluent interaction methods, awaitable expectations, and logging support via Serilog.

Tokens
5.1K
Snippets
40
Records
51
Agent score
62%

What's inside Yapoml

  1. Overview of Yapoml page object generation

    Yapoml allows developers to describe UI pages and components using a concise YAML syntax. It automatically generates fluent, type-safe C# page objects on the fly, reducing boilerplate and glue code for Selenium and Playwright tests. These generated objects are accessed via the .Ya() extension method.
  2. Overview of Yapoml for Selenium WebDriver

    Yapoml is a tool designed for fast and expressive UI test authoring that allows developers to define application pages in YAML and automatically generate fluent C# code for use with Selenium WebDriver. It aims to reduce the amount of code required to describe an application under test by providing a low-ceremony approach to interacting with UI components.
  3. Overview of Yapoml for UI Testing

    Yapoml allows developers to describe UI pages and components using a concise YAML syntax. It automatically generates fluent, type-safe C# page objects on the fly, reducing the need for manual class scaffolding and glue code. It supports both Selenium and Playwright.
  4. Overview of Yapoml for UI Testing

    Yapoml allows developers to describe web pages and components using a concise YAML syntax. It automatically generates fluent, type-safe C# page objects on the fly, reducing the need for manual class scaffolding and glue code in Selenium and Playwright tests.
  5. Overview of Yapoml for Playwright

    Yapoml is a tool designed for fast and expressive UI test authoring that integrates with Microsoft Playwright. It allows developers to define application pages using YAML, which then generates fluent C# code for interacting with UI components. The goal is to reduce the amount of code required to describe an application under test while providing a reliable, low-ceremony approach to UI automation.
  6. Generate fluent C# UI tests from YAML with Yapoml

    Yapoml allows developers to define web pages in YAML, which then automatically generates corresponding C# types. This enables a fluent API for UI testing where selectors, expectations, and interactions are available via IntelliSense. The workflow consists of installing the NuGet package, defining the page in YAML, and using the .Ya() extension method to interact with the generated page objects.
    // Define a page in YAML, get fluent C# right away.
    driver.Ya().PackagesPage.Open(q: "yapoml")
      .Packages.Expect(it => it.IsNotEmpty().Each(package =>
        {
          package.Description.IsNotEmpty();
          package.Tags.IsNotEmpty();
        })
      );
  7. Create and reuse components across pages

    To avoid duplication, define a component in a *.component.yaml file. You can then reference this component in a page or another component using the ref keyword (or its alias base).
    # Select.component.yaml
    options: ./option
    # Home.page.yaml
    sort:
      by: id sort
      ref: select # References Select.component.yaml
    // Use the reused component
    homePage.Sort.Options.First(o => o.Text.Equals(["Relevance"])).Click();
    // or shorter
    homePage.Sort.Options["Relevance"].Click();
  8. Use parametrized locators for dynamic elements

    Locators can include placeholders in curly braces (e.g., {name}) that are resolved at runtime. This works for both single components and lists of components.
    # Single component
    section: .//section[text()='{name}']
    
    # List of components
    sections: .//section[starts-with(text(), '{name}')]
    // Locates single section with "Upcoming" text
    homePage.Section(name: "Upcoming");
    
    // Locates many sections starting with "A"
    homePage.Sections(name: "A");
  9. Navigate to a page using the Open method

    The Open() method navigates to a page. This method is only available if the page has a defined url property in its YAML configuration. If the url is a relative path, a base URL must be specified in the driver configuration. The url configuration supports both simple paths and complex structures with segments and optional query parameters.
    # Home.page.yaml
    url: some/relative/path
    
    # Or with segments and query parameters
    url:
      path: /users/{userId}
      query:
        - p1
        - p2
    // Simple navigation
    ya.HomePage.Open();
    
    // Navigation with base URL
    driver.Ya(opts => opts.WithBaseUrl("https://example.com")).HomePage.Open();
    
    // Navigation with segments and query parameters
    // Navigates to /users/123?p2=any%20value
    ya.HomePage.Open("123", p2: "any value");
  10. Define pages and components using YAML files

    Pages and components in Yapoml are declared in *.page.yaml and *.component.yaml files. The project structure is mirrored in the generated code; if pages are grouped in folders, they are accessed via nested properties in the driver. For example, a file at Pages/Administration/Users.page.yaml is accessed as driver.Ya().Pages.Administration.UsersPage.
    // Accessing a page at the root
    var loginPage = driver.Ya().LoginPage;
    
    // Accessing a page in a subfolder
    var usersPage = driver.Ya().Pages.Administration.UsersPage;
  11. Integrate Serilog logging into Yapoml

    To route Yapoml component interaction log messages to Serilog, install the Yapoml.Extensions.Logging.Serilog NuGet package and enable it during driver initialization using the WithSerilog() option.
    driver.Ya(opts => opts.WithSerilog());
  12. Integrate Report Portal logging into Yapoml

    To route Yapoml component interaction log messages to Report Portal, install the Yapoml.Extensions.Logging.ReportPortal NuGet package and enable it during driver initialization using the WithReportPortal() option.
    driver.Ya(opts => opts.WithReportPortal());