机器人框架运行关键字和期望错误

时间:2017-08-24 00:51:59

标签: python python-2.7 robotframework

我在执行关键字"运行关键字并期望错误"时遇到以下问题在机器人框架中。

首先我尝试了这个:

run keyword and expect error    InvalidElementStateException: Message: invalid element state: Element is not currently interactable and may not be manipulated  Input Text  ${indFNPatientHealth Link}  RCIGM_FN

它失败了。回溯是:

17:44:01.894    FAIL    InvalidElementStateException: Message: invalid element state: Element is not currently interactable and may not be manipulated
  (Session info: chrome=60.0.3112.101)
  (Driver info: chromedriver=2.30.477700 (0057494ad8732195794a7b32078424f92a5fce41),platform=Windows NT 6.1.7601 SP1 x86_64)
17:44:01.894    FAIL    Expected error 'InvalidElementStateException: Message: invalid element state: Element is not currently interactable and may not be manipulated' but got 'InvalidElementStateException: Message: invalid element state: Element is not currently interactable and may not be manipulated
  (Session info: chrome=60.0.3112.101)
  (Driver info: chromedriver=2.30.477700 (0057494ad8732195794a7b32078424f92a5fce41),platform=Windows NT 6.1.7601 SP1 x86_64)
'.

所以我修改了复制全文的预期错误,包括会话信息和驱动程序信息。更新的代码是:

run keyword and expect error    InvalidElementStateException: Message: invalid element state: Element is not currently interactable and may not be manipulated \ \ (Session info: chrome=60.0.3112.101) \ \ (Driver info: chromedriver=2.30.477700 (0057494ad8732195794a7b32078424f92a5fce41),platform=Windows NT 6.1.7601 SP1 x86_64)    Input Text    ${indFNPatientHealth Link}    RCIGM_FN

它又失败了。

17:31:59.291    FAIL    InvalidElementStateException: Message: invalid element state: Element is not currently interactable and may not be manipulated
  (Session info: chrome=60.0.3112.101)
  (Driver info: chromedriver=2.30.477700 (0057494ad8732195794a7b32078424f92a5fce41),platform=Windows NT 6.1.7601 SP1 x86_64)
17:31:59.291    FAIL    Expected error 'InvalidElementStateException: Message: invalid element state: Element is not currently interactable and may not be manipulated   (Session info: chrome=60.0.3112.101)   (Driver info: chromedriver=2.30.477700 (0057494ad8732195794a7b32078424f92a5fce41),platform=Windows NT 6.1.7601 SP1 x86_64)' but got 'InvalidElementStateException: Message: invalid element state: Element is not currently interactable and may not be manipulated
  (Session info: chrome=60.0.3112.101)
  (Driver info: chromedriver=2.30.477700 (0057494ad8732195794a7b32078424f92a5fce41),platform=Windows NT 6.1.7601 SP1 x86_64)

提前感谢您对解决此问题的支持。

1 个答案:

答案 0 :(得分:1)

您尝试捕获的字符串非常长,可变且包含行跳过。此外,调试数据与您的测试无关。如果我是你,我只是抓住整个消息,将*传递给Run Keyword And Expect Error,然后使用部分字符串匹配关键字来确保我发现了InvalidElementStateException异常。您也可以将消息添加到部分检查,但删除变量调试数据。

请参阅Run Keyword And Expect Error

像这样的东西

${msg}=    Run Keyword And Expect Error    *    Input Text    ${indFNPatientHealth Link}    RCIGM_FN
Should Contain    ${msg}    InvalidElementStateException