在机器人框架中执行关键字"运行关键字并期望错误"时,我面临以下问题。
首先我尝试了这个:
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)
提前感谢您对解决此问题的支持。
您尝试捕获的字符串很长,可变且包含跳行。此外,调试数据与您的测试无关。如果我是你,我只会捕获整个消息,*
传递给Run Keyword And Expect Error
,然后使用部分字符串匹配关键字来确保我捕获了InvalidElementStateException
异常。您也可以将消息添加到部分检查中,但删除变量调试数据。
请参阅运行关键字并预期错误
像这样的东西
${msg}= Run Keyword And Expect Error * Input Text ${indFNPatientHealth Link} RCIGM_FN
Should Contain ${msg} InvalidElementStateException