LeonardoQAC
LeonardoQAC

Reputation: 11

Can't use "Generate Random String" keyword on Robot Framework

I'm new with RobotFramework. I want to use the "Generate Random String" keyword but the system doesn't recognize it as a valid one, although I'm importing the String Library. Maybe is outdated? How can I update a "built-in" library in Robot Framework?

I'm using Python 2.7.10 with Pycharm CE

Sorry if I don't provide all the info needed, is my first question here.

Upvotes: 0

Views: 3095

Answers (1)

aneroid
aneroid

Reputation: 15987

What does your current test look like? Generate Random String is part of the String library. While it is included when you install RobotFramework, you have to explicitly import the Library in the Settings section.

***Settings***
Library    String

Keyword: Generate Random String length=8 chars=[LETTERS][NUMBERS]

Example usage from the documentation:

${ret} =    Generate Random String      
${low} =    Generate Random String    12    [LOWER]
${bin} =    Generate Random String    8     01
${hex} =    Generate Random String    4     [NUMBERS]abcdef

Edit: Full example test:

*** Settings ***
Library    String

*** Test Cases ***
Random Stuff
    ${ret}=    Generate Random String
    ${low}=    Generate Random String    12    [LOWER]
    ${bin}=    Generate Random String    8     01
    ${hex}=    Generate Random String    4     [NUMBERS]abcdef

The logs show the random values it gets: xcc3XUjZ, iuuvcqxvamam, 01000000, 4ce2. Without posting the script you're using and some of the error, we can't help further.

Upvotes: 2

Related Questions