2017-08-24 53 views
0

在Robot Framework中执行关键字“运行关键字并期望错误”时,我正面临以下问题。Robot Framework运行关键字和期望错误

首先我尝试这样做:

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

您试图捕捉的字符串非常长,可变且包含行跳过。此外,调试数据与您的测试无关。如果我是你,我只是想知道整个信息,通过*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 
+0

感谢。它工作完美 – nhrcpt

相关问题