I want to create after test run rook to clean data after run. For AfterScenario hooks I'm using ScenarioContext from injection:
public Hooks(ScenarioContext scenarioContext)
{
_scenarioContext = scenarioContext;
}
later I can call Pages inside scenario hooks:
var creditPage = _scenarioContext.ScenarioContainer.Resolve<CreditPage>();
I dont know however how to access page inside AfterTestRun which has to be static.
you can create a custom variable _Page and give your page object to it at the start of your test via constructor of hooks
Current page is the page which will come from page initialisation. and now _Page will remain active and you can access it in after Test
Creating your own page object is better rather than one taking from PageTest