Robotframework 当robot框架未找到元素时,如何在测试期间在控制台中显示消息?

Robotframework 当robot框架未找到元素时,如何在测试期间在控制台中显示消息?,robotframework,Robotframework,我想知道在robot framework中找不到元素时,如何在控制台中显示消息: 我试过这个: S2L.Wait Until Page Contains Element ${checkbox} 10s checkbox not found 这个元素不起作用,不知道为什么。它适用于任何其他元素,但不适用于我的复选框 所以现在我有这个: Wait Until Keyword Succeeds 5 times 2 sec S2L.Click Element ${checkbox} 但当

我想知道在robot framework中找不到元素时,如何在控制台中显示消息:

我试过这个:

S2L.Wait Until Page Contains Element  ${checkbox}  10s checkbox  not found
这个元素不起作用,不知道为什么。它适用于任何其他元素,但不适用于我的复选框

所以现在我有这个:

Wait Until Keyword Succeeds  5 times  2 sec  S2L.Click Element ${checkbox}
但当它失败时,它只会说元素未找到,但我更愿意编写个性化消息

欢迎任何帮助。
谢谢你

虽然我确实认为你的问题有所不同,但你的问题是可以回答的<代码>运行关键字和返回状态将捕获错误并继续并提供状态<代码>运行关键字如果则允许使用关键字<代码>失败,它还将在控制台上生成一条消息

*** Settings ***
Library    SeleniumLibrary

Suite Teardown    Close All Browsers 

*** Test Cases ***
Wait And Click succesfully
    Open Browser    http://google.com    HeadlessChrome
    Wait and Click Element    name:q    This should work

Wait And Click unsuccesfully
    Open Browser    http://google.com    HeadlessChrome
    Wait and Click Element    name:nobtn      This should not work

*** Keywords ***
Wait and Click Element
    [Arguments]    ${locator}    ${message}=None

    ${status}    Run Keyword And Return Status
    ...                Wait Until Keyword Succeeds  
    ...                    5 times  2 sec  
    ...                    Click Element   ${locator}

    Run Keyword If    
    ...    "${status}" == "False"
    ...    Fail     ${message}

使用Wait-Until页面包含Element关键字时可用的error参数如何

Wait Until Page Contains Element    id=elementId    timeout=60s    error=Display whatever you want, e.g. Lorem Ipsum...

请用正确的格式显示实际代码,以便我们能够准确地看到您正在做什么。我的问题是正确地格式化代码。在我点击代码图标之前很容易,但现在很难。现在清楚了吗?这是你的实际代码吗?在
10s
复选框之间是否只有一个空格?此外,您还写道“它不适用于此元素,不知道为什么。”——“不适用”是什么意思?当该语句运行时会发生什么?“不工作”在我的例子中是指当我运行测试时,如果未显示复选框,robot框架将忽略该元素。它只发生在这个元素上。10秒和复选框之间的间隔是4。谢谢Kootstra,我会试试。