Reputation: 1511
Can someone tell me what is wrong in the following code.I am trying to input text with random generated string . It works fine when i use without selenium2library . Any help would be appreciated.
Keywords.txt
***Settings***
Library Selenium2Library
Library String
*** Variables ***
${URL} https://www.google.co.in/
${Browser} Chrome
${RandomString} Generate Random String 10 [LETTERS]
*** Keywords ***
Google Input Random String
Open Browser ${URL} ${Browser}
Input Text //*[@id='lst-ib'] ${RandomString}
Close Browser
Execute.txt
*** settings ***
Library Selenium2Library
Resource Google_Test_Keywords.txt
*** Test Cases ***
Google Random String Search
Google Input Random String
Upvotes: 1
Views: 810
Reputation: 906
You cannot use keywords in variable definition block (*** Variables ***
).
Instead, populate random variables either inside your keyword:
*** Keywords ***
Google Input Random String
${RandomString}= Generate Random String 10 [LETTERS]
Open Browser ${URL} ${Browser}
Input Text //*[@id='lst-ib'] ${RandomString}
Close Browser
Or as a part of the test case:
*** Test Cases ***
Google Random String Search
${RandomString}= Generate Random String 10 [LETTERS]
Google Input ${RandomString}
You can also use setups.
Upvotes: 3