找不到名称为“删除字符串”的关键字

Tha*_*oni 1 selenium robotframework

我试图从下面提到的字符串中获取数字 70:

显示 1 到 50 个条目,共 70 个条目

我试过下面的代码:

${text} = Get Text xpath=//div[@id='DataTables_Table']
Page Should Contain Showing 1 to
${edited_text} = Remove String ${text} Showing 1 to 50 of
Run Code Online (Sandbox Code Playgroud)

但我收到以下提到的错误:

未找到名称为“删除字符串”的关键字。

即使我使用以下关键字,我也会收到相同的错误:

获取子字符串,替换字符串

A. *_*tra 7

当未找到关键字时,这通常意味着尚未加载库。除了BuiltIn库之外,所有其他库都需要声明。您的代码的完整工作示例如下:

*** Setting ***
Library    String

*** Test Cases ***
tc
    ${text}           Set Variable    Showing 1 to 50 of 70 entries
    ${edited_text}    Remove String     ${text}     Showing 1 to 50 of

    ${matches}        String.Get Regexp Matches    ${text}    [0-9]{1,2}
    Log               "Max is:" ${matches[2]}
Run Code Online (Sandbox Code Playgroud)

由于您的目的是匹配第 3 个数字组,因此正则表达式匹配似乎是最干净的方法。