将随机生成的字符串存储为变量并使用 selenium2library 将其传递给输入文本
Store random generated string as variable and pass it to input text using selenium2library
谁能告诉我以下内容有什么问题 code.I 我正在尝试使用随机生成的字符串输入文本。当我在没有 selenium2library 的情况下使用时它工作正常。任何帮助将不胜感激。
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
您不能在变量定义块 (*** Variables ***
) 中使用关键字。
相反,在您的关键字内填充随机变量:
*** Keywords ***
Google Input Random String
${RandomString}= Generate Random String 10 [LETTERS]
Open Browser ${URL} ${Browser}
Input Text //*[@id='lst-ib'] ${RandomString}
Close Browser
或者作为测试用例的一部分:
*** Test Cases ***
Google Random String Search
${RandomString}= Generate Random String 10 [LETTERS]
Google Input ${RandomString}
您也可以使用setups。
谁能告诉我以下内容有什么问题 code.I 我正在尝试使用随机生成的字符串输入文本。当我在没有 selenium2library 的情况下使用时它工作正常。任何帮助将不胜感激。
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
您不能在变量定义块 (*** Variables ***
) 中使用关键字。
相反,在您的关键字内填充随机变量:
*** Keywords ***
Google Input Random String
${RandomString}= Generate Random String 10 [LETTERS]
Open Browser ${URL} ${Browser}
Input Text //*[@id='lst-ib'] ${RandomString}
Close Browser
或者作为测试用例的一部分:
*** Test Cases ***
Google Random String Search
${RandomString}= Generate Random String 10 [LETTERS]
Google Input ${RandomString}
您也可以使用setups。