AnsibleInventoryPagePom.cs 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. using Microsoft.Playwright;
  2. namespace Tests.E2e.PageObjectModels;
  3. public class AnsibleInventoryPagePom(IPage page) {
  4. // -------------------------------------------------
  5. // Root
  6. // -------------------------------------------------
  7. public ILocator Page
  8. => page.GetByTestId("ansible-inventory-page");
  9. // -------------------------------------------------
  10. // Actions
  11. // -------------------------------------------------
  12. public ILocator GenerateButton
  13. => page.GetByTestId("generate-inventory-button");
  14. // -------------------------------------------------
  15. // Inputs
  16. // -------------------------------------------------
  17. public ILocator GroupByTagsInput
  18. => page.GetByTestId("group-by-tags-input");
  19. public ILocator GroupByLabelsInput
  20. => page.GetByTestId("group-by-labels-input");
  21. public ILocator GlobalVarsInput
  22. => page.GetByTestId("global-vars-input");
  23. // -------------------------------------------------
  24. // Output
  25. // -------------------------------------------------
  26. public ILocator InventoryOutput
  27. => page.GetByTestId("inventory-output");
  28. public ILocator WarningsContainer
  29. => page.GetByTestId("inventory-warnings");
  30. // -------------------------------------------------
  31. // High-Level Actions
  32. // -------------------------------------------------
  33. public async Task AssertVisibleAsync()
  34. => await Assertions.Expect(Page).ToBeVisibleAsync();
  35. public async Task SetGroupByTagsAsync(string value)
  36. => await GroupByTagsInput.FillAsync(value);
  37. public async Task SetGroupByLabelsAsync(string value)
  38. => await GroupByLabelsInput.FillAsync(value);
  39. public async Task SetGlobalVarsAsync(string value)
  40. => await GlobalVarsInput.FillAsync(value);
  41. public async Task GenerateAsync()
  42. => await GenerateButton.ClickAsync();
  43. public async Task<string> GetInventoryTextAsync()
  44. => await InventoryOutput.InputValueAsync();
  45. public async Task AssertInventoryContainsAsync(string text)
  46. => await Assertions.Expect(InventoryOutput).ToContainTextAsync(text);
  47. public async Task AssertNoWarningsAsync()
  48. => await Assertions.Expect(WarningsContainer).ToHaveCountAsync(0);
  49. public async Task AssertWarningContainsAsync(string text)
  50. => await Assertions.Expect(WarningsContainer).ToContainTextAsync(text);
  51. }