4
0

AnsibleInventoryPagePom.cs 2.4 KB

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