0

I am using Cucumber+Selenium+junit for automating test cases.

Sample scenario is mentioned below. I pass multiple examples for different environments into the scenario. In my test application the passwords keep on changing every 60 days and updating these passwords in every feature file is very cumbersome. Could you please help me how I can parameterise these username and passwords and pass it from separate config file, so that every time the passwords changes i can update them at a single place.

Scenario Outline: Verify the login functionality in xyz application

Given I open the browser

And I launch the xyz application <url>

When I enter the <username> and <password>

And click on sign in button

Then User should login successfully

Examples

@SIT

|url |username |password|

|sit.com|situser|sitpassword|



@UAT

|url |username |password|

|uat.com|uatuser|uatpassword|



@Training

|url |username |password|

|training.com|traininguser|trainingpassword|
Greg Burghardt
  • 17,900
  • 9
  • 49
  • 92
sown
  • 1
  • 1
  • 1

1 Answers1

2

Just write scenarios without the credentials in them. Then get the passwords in your step definitions

You could write scenarios like

Given I am registered on UAT
When I login into UAT
Then I should be logged in

and then something like

module EnvTesterSH
  def get_current_creds(env: )
    ...
    [id, password]
  end
end
World EnvTesterSH

Given 'I am registered on UAT' do
  @id, @password = get_current_creds(env: :uat)
end

and now your problem is how do you write code to get the new credentials, which I guess all depends on who or what changes the credentials. But now you at least have a programming language to help you.

diabolist
  • 3,990
  • 1
  • 11
  • 15
  • I think you are on to the right answer, but the person asking the question is using Java. I just added that tag to the question, because it was also tagged with junit, which is a Java unit testing framework. Any chance you want to try your hand at a little Java? – Greg Burghardt Jan 24 '20 at 21:53
  • No chance at all ;). Sorry its been too long since I used java and the experience is too painful for me, especially when cuking. However there should be quite a bit of help at cucumber.io in the docs to do what I am doing here but with Java, and I've been assured by the cuke devs that it is possible in java. – diabolist Jan 28 '20 at 14:09