Is there anyway where we can use if/else concept in feature file? For example:
Scenario: User should be able to check login page
Given I am on login page
When I click on SignIn button
Then I should be in home page
If yes
Then I will create a new profile
Else
Then I will logout from page
No you can't and you shouldn't. Feature files are for business behaviour, not programming.
From your scenario I think you are trying to deal with different behaviour, depending on whether you are registered or not. To do this you would write two scenarios
Notice how these scenarios don't describe 'how' anything is done. Anything like `I click on foo' in feature is a smell and should be avoided.
Not that I am aware of. Gherkin (and cucumber) are best used when they specify discreet business cases though, and should be repeatable, else they get hard to follow and test. It looks like you have two stories here at least:
What about if we are using Gherkin in a smoke test type situation and we need to ensure something exists in the database using only the UI?
The re-use of the same
Then
step twice is essentially an if-else that will make sure my Box exists so that I can run my other tests in the smoke test suite that require a Box.But that is dependent on being able to stop the Scenario execution in the test runner or doing something extraneous like:
ScenarioContext.Current["TestPassed"] = true;
and then in each of the steps
if(ScenarioContext.Current.Get<bool>("TestPassed")) return;
You can use parameter in feature file and implement the If else in the Code based on the parameter passed.