Ray
Ray

Reputation: 807

RobotFramework: How to set random number as a constant in resources file

I want to do generate a random number for the value, but the resources file doesn't allow to use keywords as far as I am aware. Is there a way to do this? As I need a random value every time I run the cod. The value is then used by 2 scripts.

*** Settings ***
Resource        resources/resources.txt
Library         RequestsLibrary
Library         Collections
Library         DatabaseLibrary

*** Variables ***
${ENVIRONMENT_TO_RUN_AGAINST}       https://sw3-test.site.com
${auth_key}                         1111122

Upvotes: 0

Views: 1182

Answers (1)

Bryan Oakley
Bryan Oakley

Reputation: 386220

You can create a keyword that generates a random key, and then use that in a suite setup in your test case files.

I'm not sure what you mean by "used by 2 scripts". I if you mean "2 test cases in a suite" you can set a suite-level variable. If you mean "2 different suites" you can set a global variable.

*** Keywords ***
Generate random auth key
    ${auth}=  blah blah blah
    set suite variable    ${auth}

*** Settings ***
Suite Setup    generate random auth key

Upvotes: 1

Related Questions