Generate UUID

687 views
Skip to first unread message

Dave de bruin

unread,
Jul 26, 2019, 11:15:57 AM7/26/19
to robotframework-users
I am searching for an example of a keyword that generate a UUID 
and then from my test fill a variable with this UUID  

I found an example for the keyword 
Generate UUID
${uuid}= Generate UUID
${generated_uuid}= Get Regexp Matches ${uuid} ^(?P<uuid>[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}).* uuid
Should Not Be Empty ${generated_uuid}

but I do not manage to fill a variable in my test 

*** Test Cases ***
DSB-IN-19954-001 GetVRs
[Tags] DSB-IN-19954-001 DSB-IN-19954 ART
${recordId} Generate UUID

when I do this I get a error Maximum limit of started keywords exceeded.
No keyword with name 'Get Regexp Matches' found.

anyone who can help   ??
tnx 

Tatu Aalto

unread,
Jul 26, 2019, 11:48:31 AM7/26/19
to davedeb...@gmail.com, robotframework-users
Ugh

Instead of generating UUID in Robot Framework data, I would expose UUID from the Python side[1] as a library keyword [2].

-Tatu
Send from my mobile

--
You received this message because you are subscribed to the Google Groups "robotframework-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to robotframework-u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/robotframework-users/b476a6c4-f0c3-42a0-9576-e6885fde1db1%40googlegroups.com.

Wlad

unread,
Jul 27, 2019, 4:00:46 AM7/27/19
to davedeb...@gmail.com, robotframework-users
*** Keywords ***
Generate UUID
    [Documentation]     Generates a random UUIDv4 spec conform `uuid`.

    ${id}=              Evaluate    uuid.uuid4()    uuid
                        Set Test Variable    ${uuid}    ${id}


image.png

Cheers


--

Wlad

unread,
Jul 27, 2019, 4:16:37 AM7/27/19
to davedeb...@gmail.com, robotframework-users
instead of exposing variable to test scope level like in my last example you can just return it:


*** Keywords ***
Generate UUID
    [Documentation]     Generates a random UUIDv4 spec conform `uuid`.

    ${uuid}=            Evaluate    str(uuid.uuid4())    uuid

    [RETURN]            ${uuid}


*** Test Cases ***
simple test

    ${uuid}=        Generate UUID
                    Log To Console      ${uuid}


NOTE: consider returning it as string --> str()  because uuid.uuid4() will return a uuid object which may be not what you want.

image.png

Cheers

Am Fr., 26. Juli 2019 um 17:16 Uhr schrieb Dave de bruin <davedeb...@gmail.com>:
--
Reply all
Reply to author
Forward
0 new messages