| name | staf-page-action |
|---|---|
| description | Creates STAF page objects (PageBaseClass, FindAppElement, locator regions) and action flows (inherit page, ReportResult, fluent returns). Use when adding screens, POM classes, or Login-style flows. |
-
Create Page
{Screen}Page.csinSTAFTests/Pages/- Inherit
PageBaseClass - Define locators in
#region ObjectIdentifierValues - Create properties returning
FindAppElement(By.*, selector, "description")
- Inherit
-
Create Action
{Screen}.csinSTAFTests/Actions/- Inherit the page class
- Add methods:
DoSomething()(user action),VerifyXLoaded()(check state) - Return
this(stay) ornew NextScreen(driver, context)(navigate) - Every step:
ReportResult.ReportResultPass/Fail(...)
-
Update symbol index (once per session)
- Run:
pwsh tools/UpdateAiIndex.ps1
- Run:
-
Add tests using skill staf-ui-test
- Call action methods from test class inheriting
TestBaseClass
- Call action methods from test class inheriting
public class MyScreenPage : PageBaseClass
{
#region ObjectIdentifierValues
private string _btnSubmit = "submit";
private string _lblMessage = ".error-message";
#endregion
public MyScreenPage(IWebDriver driver, TestContext context)
: base(driver, context) { }
public IWebElement btnSubmit => FindAppElement(By.Id(_btnSubmit), "Submit button");
public IWebElement lblMessage => FindAppElement(By.CssSelector(_lblMessage), "Error message");
}public class MyScreen : MyScreenPage
{
public MyScreen(IWebDriver driver, TestContext context)
: base(driver, context) { }
public MyScreen VerifyPageLoaded()
{
btnSubmit.ReportElementIsDisplayed(
Driver, context, nameof(VerifyPageLoaded),
"Submit button visible", false);
return this;
}
}public NextScreen ClickSubmit()
{
var testName = nameof(ClickSubmit);
try
{
Click(btnSubmit);
ReportResult.ReportResultPass(Driver, context, testName, "Clicked submit");
}
catch (Exception ex)
{
ReportResult.ReportResultFail(Driver, context, testName, $"Failed: {ex.Message}");
Assert.Fail($"Failed: {ex.Message}");
}
return new NextScreen(Driver, context);
}- Page inherits
PageBaseClass, action inherits page - Locators in
#region ObjectIdentifierValuesas private strings - All element properties use
FindAppElement(By.*, selector, "description") - Action methods have descriptive names:
VerifyPageLoaded(),ClickSubmit(),EnterUserName() - Every step calls
ReportResult.ReportResultPass/Fail(...)withnameof(CurrentMethod) - Methods return
this(fluent on same page) ornew NextPage(driver, context)(navigate) - Public methods have XML comments:
/// <summary> - No
Thread.Sleep, no rawdriver.FindElement, no hardcoded WebDriver - File naming matches class naming:
LoginPage.cs→public class LoginPage
| Platform | How to Use | Setup |
|---|---|---|
| Visual Studio | GitHub Copilot chat | See .github/copilot-instructions.md |
| VS Code | Copilot Chat (Ctrl+Shift+I) |
See .vscode/README.md |
| Cursor | Composer or Cmd+K | Reference this skill by name |
- Page:
STAFTests/Pages/LoginPage.cs— Locator structure, XML comments - Action (verification):
STAFTests/Actions/AboutUs.cs— Verify page state, returnthis - Action (flow):
STAFTests/Actions/Login.cs— User actions, fluent chains, navigate to next
📖 Master documentation: docs/ai/AI_GUIDE.md
Templates & examples: reference.md