【问题标题】:robotframework - No keyword with name 'Split String' found机器人框架 - 找不到名称为“拆分字符串”的关键字
【发布时间】:2020-07-07 15:50:45
【问题描述】:

问题描述

我无法按照指南here 中的说明将字符串拆分为标记 它不断抛出“没有找到名称为'Split String'的关键字”,我不确定我做错了什么。显然,我一定错过了一些我看不到的东西。

我使用这个命令来运行测试:robot publish-api-mule.robot

publish-api.robot

*** Settings ***
Documentation     Publish an API in Mule Server
Resource          resource.robot

*** Test Cases ***
Valid Login
    Open Browser To Login Page
    Input Username    <username%%%%%%%>
    Input Password    <passwprd%%%%%%%%>
    Submit Credentials
    Welcome Page Should Be Open
    CLick on API Manager
    Select Environment  TEST
    Click on Manage from API Exchange
    Input API to Deploy and Save  customer-api-services
    Select API Version  1.0.4
    Select Asset Version  5.0.2
    Save and Publish API
    Copy API ID and Autodiscovery hash
    Apply Policies  logging-init-policy, common-response-headers-policy, Client_id Enforcement policy, jwt-validation-policy
    Share Details in JIRA via Comment  SAPIM-52
    [Teardown]    Close Browser

resource.robot

*** Settings ***
Documentation     A resource file with reusable keywords and variables.
...
...               The system specific keywords created here form our own
...               domain specific language. They utilize keywords provided
...               by the imported SeleniumLibrary.
Library           SeleniumLibrary


*** Variables ***
@{POLICIES}                 []
${SERVER}                   anypoint.mulesoft.com
${BROWSER}                  Chrome
${DELAY}                    0
${LOGIN URL}                https://${SERVER}/login
${JIRA_API_ID}              -
${JIRA_AUTODISCOVERY_HASH}  -
${API_ID}                   -
${AUTODISCOVERY_HASH}       -

*** Keywords ***
Open Browser To Login Page
    Open Browser    ${LOGIN URL}    ${BROWSER}
    Maximize Browser Window
    Set Selenium Speed    ${DELAY}
    Login Page Should Be Open

Login Page Should Be Open
    Title Should Be    Anypoint Platform

Go To Login Page
    Go To    ${LOGIN URL}
    Login Page Should Be Open

Input Username
    [Arguments]    ${USERNAME}
    Input Text  //*[@id="appRoot"]/main/div/div/div/div[1]/form/div[1]/div/div/input    ${USERNAME}

Input Password
    [Arguments]    ${PASSWORD}
    Input Text  password    ${PASSWORD}

Submit Credentials
    Click Element    //*[@id="appRoot"]/main/div/div/div/div[1]/form/button

Welcome Page Should Be Open
    Title Should Be    Anypoint Platform

CLick on API Manager
    Wait Until Element Is Enabled     //*[@id="appRoot"]/div/div/section[1]/div/div[2]/div/ol/li[2]/a/div/span[1]
    Click Element    //*[@id="appRoot"]/div/div/section[1]/div/div[2]/div/ol/li[2]/a/div/span[1]

Select Environment
    [Arguments]     ${ENVIRONMENT}
    Wait Until Element Is Enabled     //div[contains(text(),'${ENVIRONMENT}')]
    Click Element    //div[contains(text(),'${ENVIRONMENT}')]

Click on Manage from API Exchange
    Wait Until Element Is Enabled     //*[@id="contentWrapper"]/ui-view/ui-view/div/div/div/div[2]/div[1]/div[1]/button/div[2]
    Click Element       //*[@id="contentWrapper"]/ui-view/ui-view/div/div/div/div[2]/div[1]/div[1]/button/div[2]
    Wait Until Element Is Enabled   //*[@id="contentWrapper"]/ui-view/ui-view/div/div/div/div[2]/div[1]/div[1]/ul/li[1]/a
    Click Element    //*[@id="contentWrapper"]/ui-view/ui-view/div/div/div/div[2]/div[1]/div[1]/ul/li[1]/a

Input API to Deploy and Save
    [Arguments]    ${API NAME}
    Set Focus To Element        //*[@id="am-get-from-exchange-container"]/div/form/div[1]/div[1]/div/div/div
    Wait Until Element Is Enabled   //*[@id="am-get-from-exchange-container"]/div/form/div[1]/div[1]/div/div/div
    Input Text  //*[@id="react-select-2--value"]/div[2]/input      ${API NAME}
    Sleep   2s
    Mouse Down  //*[contains(text(), "${API NAME}")]
    Press Keys  xpath=//body    TAB

Select API Version
    [Arguments]     ${API VERSION}
    Wait Until Element Is Enabled   //*[@id="am-get-from-exchange-container"]/div/form/div[1]/div[3]/div/div/div
    Click Element   //*[@id="am-get-from-exchange-container"]/div/form/div[1]/div[3]/div/div/div
    Wait Until Element Is Enabled       //*[contains(text(),'${API VERSION}')]
    Click Element        //*[contains(text(),'${API VERSION}')]

Select Asset Version
    [Arguments]     ${ASSET VERSION}
    Wait Until Element Is Enabled       //*[@id="am-get-from-exchange-container"]/div/form/div[1]/div[4]/div/div/div/div/span[2]/span
    Click Element       //*[@id="am-get-from-exchange-container"]/div/form/div[1]/div[4]/div/div/div/div/span[2]/span
    Wait Until Element Is Enabled       //*[contains(text(),'${ASSET VERSION}')]
    Click Element        //*[contains(text(),'${ASSET VERSION}')]

Save and Publish API
    Click Element    //*[@id="save-button"]/span
    Wait Until Element Is Enabled   //*[@id="contentWrapper"]/ui-view/ui-view/div/div/div/ap-api-version-header/div[1]/div/div[1]/div/div[1]/span

Copy API ID and Autodiscovery hash
    ${API_ID}=  Get Text    //*[@id="contentWrapper"]/ui-view/ui-view/div/div/div/ap-api-version-header/div[1]/div/div[2]/div[2]/div[1]/span[2]
    Set Suite Variable  ${JIRA_API_ID}  ${API_ID}
    Wait Until Element is Enabled   //*[@id="autodicovery-props"]/span/div/button
    ${AUTODISCOVERY_HASH}=  Get Element Attribute   //*[@id="autodicovery-props"]/span/div/button   attribute=data-clipboard-text
    Set Suite Variable  ${JIRA_AUTODISCOVERY_HASH}  ${AUTODISCOVERY_HASH}

Apply Policy
    [Arguments]     ${POLICY_NAME}
    Click Element   //*[@id="contentWrapper"]/div/ap-left-sidebar/div/ul[2]/li[3]/a
    Wait Until Element is Enabled   //*[@id="contentWrapper"]/ui-view/ui-view/div/div/ui-view/div/div[3]/div/div[1]/button
    Click Element   //*[@id="contentWrapper"]/ui-view/ui-view/div/div/ui-view/div/div[3]/div/div[1]/button
    Mouse Down      //label[contains(text(), "${POLICY_NAME}-v${POLICY_VERSION}")]
    Click Element   /html/body/div[7]/div/div/div[3]/button[2]

Apply Policies
    [Arguments]     ${ALL_POLICIES_COMMA_SEPARATED}
    @{POLICIES}=    Split String       ${ALL_POLICIES_COMMA_SEPARATED}     ,${SPACE} 
    :FOR    ${POLICY}    IN    @{POLICIES}
    Apply Policy  ${POLICY}

Share Details in JIRA via Comment
    [Arguments]     ${JIRA NUMBER}
    Go to   https://jira-sdop.us.corp/browse/${JIRA NUMBER}
    Wait Until Element is Enabled   //*[@id="dprAdapters"]
    Select From List By Index   //*[@id="dprAdapters"]  3
    Submit Form
    Wait Until Element is Enabled   footer-comment-button
    Click Element   footer-comment-button
    Wait Until Element Is Enabled   //*[@id="comment"]
    Sleep   1s
    Input Text  //*[@id="comment"]      ${JIRA_API_ID} \n\n ${JIRA_AUTODISCOVERY_HASH}
    Click Element   //*[@id="issue-comment-add-submit"]

Robotframework 抱怨“拆分字符串”是下面这个块的一部分

Apply Policies
    [Arguments]     ${ALL_POLICIES_COMMA_SEPARATED}
    @{POLICIES}=    Split String       ${ALL_POLICIES_COMMA_SEPARATED}     ,${SPACE} 
    :FOR    ${POLICY}    IN    @{POLICIES}
    Apply Policy  ${POLICY}

说明以下错误:

No keyword with name 'Split String' found.

我在这个版本上运行

$ robot --version
Robot Framework 3.2.1 (Python 2.7.16 on win32)

【问题讨论】:

  • 您似乎没有在任何地方导入String 库。
  • 我的错。我认为该库是框架的核心。谢谢

标签: arrays string split robotframework


【解决方案1】:

即使String 库带有机器人框架,您也必须将其导入测试文件才能使用关键字。

例如:

*** Settings ***
Library    String

【讨论】:

    猜你喜欢
    • 2019-12-21
    • 2017-09-18
    • 2015-01-10
    • 2015-08-12
    • 2019-01-01
    • 2019-07-04
    • 1970-01-01
    • 2015-03-06
    相关资源
    最近更新 更多