1

I am calling keyword for suite setup as below

Suite setup  setup keyword

But can I call python file from suite setup or keywords file? I have lot of keywords as setup so is there any way I can pass them all together? I can use run keywords to pass multiple keywords but can I pass file?

3
  • 1
    You can create a single keyword consisting of many other keywords and run it. Commented Dec 22, 2015 at 8:29
  • Have you tried specifying a file in Suite Setup? Does it work? If not, what's the error? Commented Jan 8, 2016 at 14:54
  • I added python files as variables in settings and it worked Commented Jan 12, 2016 at 3:10

1 Answer 1

1

You can't give a filename as an argument to a suite setup, but you can certainly create a file that has a single keyword that does everything you want.

You could also use a variable file, which will get executed before any tests will run.

Using a library file with a setup keyword

To use a library file, put all the code you want to execute in a single function. For example:

# my_setup_file.py
def my_setup():
    do_something()
    do_something_else()

You could then use it like this:

# my_suite.robot
*** Settings ***
| Library | my_setup_file.py
| Suite setup | my_setup

Using a variable file

You can use a variable file, which in effect works like loading up a file in setup since the file is evaluated before the start of the first step (and before any other setup steps)

In this case your python file would not need a function, it could have any code. All variables defined in this file will be available to your test case.

# my_variables.py
foo = "this is foo"
bar = "this is bar"

You would then use it like this:

*** Settings ***
| Variables | my_variables.py
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.