0

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 
shashank shekhar
  • 155
  • 3
  • 16
  • Which unit test framework are you using, and which test runner are you using? – Greg Burghardt Apr 12 '23 at 12:33
  • Never mind. I see you are using XUnit. Which version of XUnit and SpecFlow are you using? – Greg Burghardt Apr 12 '23 at 12:38
  • And can you add information about the task in your Azure pipeline that runs the tests? – Greg Burghardt Apr 12 '23 at 12:39
  • @GregBurghardt i am using xunit 2.4.1 – shashank shekhar Apr 13 '23 at 05:01
  • @GregBurghardt i am using xunit 2.4.1. I dont think the issue is with azure pipeline as the same issue occurs when i run this in debug mode locally. by the way the task i run is ``` -task: DotNetCoreCLI@2 displayName: ‘Run test’ Inputs: command: test publishTestResults: false projects:$(Build.SourceDirectory)/path arguments: > —no-build —no-restore —logger try ``` could issue be with either specflow or maybe thread issue. – shashank shekhar Apr 13 '23 at 05:08
  • Please [edit] your question to include that information. It is too hard to read in a comment. Note that inline code should be formatted as `\`code here\`` --- single back-ticks. – Greg Burghardt Apr 13 '23 at 15:37

0 Answers0