简体   繁体   English

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

[英]Robot Framework Run Keyword and Expect Error

I am facing the following issue when executing keyword "Run Keyword and expect Error" in Robot Framework. 在Robot Framework中执行关键字“运行关键字并期望错误”时,我面临以下问题。

First I tried this: 首先,我尝试了这个:

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

and it failed. 失败了 The trace back is: 追溯为:

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)
'.

So I modified the expected error copying the full text including session info and driver info. 因此,我修改了复制全文(包括会话信息和驱动程序信息)的预期错误。 The updated code is: 更新的代码是:

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

And It failed again . 而且它再次失败了。

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)

Thanks in advance for your support for solving this. 预先感谢您对解决此问题的支持。

The string you're trying to catch is quite long, variable and contains line skips. 您尝试捕获的字符串非常长,可变且包含跳行。 Also, the debug data is kind of irrelevant to your test. 另外,调试数据与您的测试无关。 If I was you I'd just catch the whole message, passing * to Run Keyword And Expect Error and then use a partial string match keyword to ensure I caught a InvalidElementStateException exception. 如果我是您,我将捕获整个消息,将*传递给Run Keyword And Expect Error ,然后使用部分字符串match关键字以确保捕获了InvalidElementStateException异常。 You may also add your message to the partial check, but remove the variable debug data. 您也可以将消息添加到部分检查中,但删除变量调试数据。

See Run Keyword And Expect Error 请参阅运行关键字并期待错误

Something like this 像这样

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM