1.Is there anyway to share methods between tests ? something like using global methods. Lets say I have a login procedure I want to use in some of my tests , do I have to define it as a custom keyword or can I define a method and share it between tests?
2.Can I define a global “setup/teardown” method for the whole test suite? or is it only possible to define setup for each test individually ?
3.Can I define a set of custom keywords and repository objects and pack them as an external library to share between projects ?
I think you should
First start a Spy Web Session.
Navigate to the target screen in your application ( Ensure that no objects are added or selected until you reach your target screen).
From the target screen capture the target object
Click Add to Object Repository
Uncheck the Create New folder(s) as Page’s Name
Select and existing folder as destination folder and Click Ok.
The new object get added to the list of objects in the existing folder
Hi , another question I have is regarding the object repository - every time I record , the captured elements are added to another new folder under the object repository. The problem I have is that I already have those objects from previous tests I recorded , So now they are duplicated . I know I can choose not to save the new ones , but that will make me have to change the recorded script to use the old ones.Is there a way to avoid this case and make it compare the objects to the current repository and find duplicates? If not it will be a very important feature to have.
Hi , it is possible to call from a keyword to another , I do it a lot - just import the class of the keyword you want to use to the new keyword class and call the old keyword function within the new one. Make sure it is a static function.
I agree with @Nir , defining tear down and set up in test suite level can help to avoid code duplication (login / close browser)
or maybe something like a “parent” test case that test cases can inherit from .
about sharing keywords between testcases -
is it possible to have a keywords method that calls another keyword method ?
say we have a keyword that select dropdown values , and a keyword that is checking if a a result table shows a specific value
what if we want to have a thirs keywords that does "select a value and check if it appears in the result table -> hence having the one keyword calling the other .
is that possible ?
OK,Test suite common setup can be a nice feature in the future since this is the way people usually work in junit/nunit.
Thank you !
Custom keyword is shared between test cases. You can define your own custom keyword and use it between other test cases if you want to.
Test Suite current doesn’t support the ability to define ‘setup/teardown’ in that level. They are only available in test case level.
You can define a set of custom keywords and objects then share them to other projects by copying them to relative folders