I am writing a specflow+playwright+xunit test framework where my test step in feature file is like below.
Given I launch web app
And I entered <userId> and <password> and click submit
When I select x radio for option <optnName>
for second step the implementation code is as below-
[Given(@"I entered (.*) and (.*) and click submit")]
public async void method(string userId, string password)
{
await pageFactory.MainMenuPage.UserNameField.ClearAsync();
await pageFactory.MainMenuPage.UserNameField.TypeAsync(userId);
await pageFactory.MainMenuPage.PasswordField.ClearAsync();
await pageFactory.MainMenuPage.PasswordField.TypeAsync(password);
await pageFactory.MainMenuPage.LoginBtn.ClickAsync();
}
for third step method is as below-
[When(@"I select the x radio for option (.*)")]
public async Task method2(string optn)
{
await pageFactory.NewDisclosurePage.selectradio(optn);
await pageFactory.NewDisclosurePage.continueBtn.clickAsync();
}
In PageFactory class all the pageClasses are instantiated like below
public PageFactory(IPage page1)
{
page = page1;
commonPageObject = new CommonPage(page);
MainMenuPage = new MainMenuPage(page);
NewDisclosurePage = new newDisclosure(page);
}
The problem is when i run the test in debug mode or in azure CI the test step starts run
and in the second method after it goes to await pageFactory.MainMenuPage.UserNameField.TypeAsync(userId);
it directly jumps to NewDisclosure class i.e 3rd step and then again comes back to second step. obviously when it goes to third step , it is not able to identify radio optn field and it fails. in ## Heading ##normal mode test runs all good without issue.
Note: i have check the Debug-->options -->Enable my code(check /uncheck). it is not working anyways.
I tried changing factory pattern but does not seem to resolve
CI yml task
-task: DotNetCoreCLI@2
displayName: ‘Run test’
Inputs:
command: test
publishTestResults: false
projects:$(Build.SourceDirectory)/path arguments: > —no-build —no-
restore —logger try