cerberustesting / cerberus-core

The Open Source Test Automation Platform.
https://cerberus-testing.com
GNU General Public License v3.0
329 stars 100 forks source link

Documentation] How to pass a property to library? #2548

Closed cencio91 closed 2 weeks ago

cencio91 commented 2 weeks ago

Hi, I wonder How to pass a property to an action that is marked as library.

For example, my reusable action "login" could be used in different test case, and based on test requirements, it should be called with a different property "username" so I can choose to login as admin, user ecc.

How to accomplish this?

thank you very much

vertigo17 commented 2 weeks ago

Hello @cencio91 , in order to achieve that I would more suggest the following: A login step that include the action to type %property.LOGIN% to the corresponding field + all other necessary actions in order to login. That step should be marked as library. On that test case you can define the default value for property LOGIN to user.

On a first test case that need to login with user, you just need to link the library step with no changes. The property will be inherited from the original value.

On a second testcase that need admin login, you can still link the same library step. On top of that, just add to that specific test case the same property LOGIN with the value admin. That value will overwrite the original value defined from the library.

Same mecanism can be used with password and any other property.

NB: If you want to secure pass at execution level you can name your property so that it contains PASSW. ex PASSWORD If you want to secure it everywhere, put it in a datalib and flag it as encrypted.

vertigo17 commented 2 weeks ago

Some documentation could help you:

https://qa.cerberus-testing.com/documentation/D1/documentation_en.html#_test_case_property

https://qa.cerberus-testing.com/documentation/D1/documentation_en.html#_test_case_variables

cencio91 commented 2 weeks ago

Hi vertigo, thank you very much for your comphrensive explaination. From documentation I missed the parameter override, but now it's clear.

I wish you a nice day, Francesco