机器人框架+AutoIt:字典不包含键
-
02-01-2020 - |
题
我目前正在玩弄 [医]自动 图书馆 机器人框架, ,所以我正在做典型的"我的第一个"机器人GUI测试和测试计算器!不幸的是,我下面的代码生成错误: Dictionary does not contain key 'View Scientific'.
.这发生在 启动计算器 关键字。似乎每当我打电话 选择计算器菜单项 我得到一个错误。
*** Settings ***
| Documentation | Tests AutoIt Library
| Suite Setup | Start Calculator
| Library | AutoItLibrary
| Library | Collections
| Library | String
| Variables | CalculatorGUIMap.py
*** Test Cases ***
| Integer Addition
| | Click Buttons | 2 2 + 2 =
| | Win Wait | Calculator | 24
| | ${Ans}= | Get Answer
| | Should Be Equal As Numbers | ${Ans} | 24
*** Keywords ***
| Start Calculator
| | Run | calc.exe
| | Wait For Active Window | Calculator
| | Get Calculator Version
| | Select Calculator Menu Item | View Scientific
| | Send | 12345
| | ${Result} | ${ErrMsg} = | Run Keyword And Ignore Error | Win Wait
| | ... | Calculator | 12345
| | Run Keyword If | "${Result}"=="FAIL" | Select Calculator Menu Item | View Digit grouping
| | Win Wait | Calculator | 12345
| | Click Button | Clear
| Click Button
| | [Arguments] | ${Button Text}
| | ${ButtonName} = | Get From Dictionary | ${GUIMAP} | ${ButtonText}
| | Control Click | Calculator | ${EMPTY} | ${ButtonName}
| Click Buttons
| | [Arguments] | ${ButtonNames}
| | @{Buttons}= | Split String | ${ButtonNames}
| | :FOR | ${ButtonName} | IN | @{Buttons}
| | | Click Button | ${ButtonName}
| Select Calculator Menu Item
| | [Arguments] | ${MenuItem}
| | ${AltKeys}= | Get From Dictionary | ${MENUMAP} | ${MenuItem}
| | Send | {ALTDOWN}
| | Sleep | 1
| | Send | ${AltKeys}
| | Send | {ALTUP}
| Get Calculator Version
| | Send | {ALTDOWN}
| | Sleep | 1
| | Send | ha
| | Send | {ALTUP}
| | Win Wait Active | About Calculator | Version
| | ${WinText}= | Control Get Text | About Calculator | Version | 13579
| | ${WinText2}= | Run Keyword If | "Version" not in "${WinText}" | Control Get Text
| | ... | About Calculator | Version | Static4
| | ${WinText}= | Set Variable If | "version" in "${WinText2}" | ${WinText2}
| | ... | ${WinText}
| | Run Keyword If | "Version" not in "${WinText}" | Fail | Can't find Calculator version
| | ${GUIMAP}= | Set Variable If | "5.1" in "${WinText}" | ${GUIMAP_51}
| | ${GUIMAP}= | Set Variable If | "6.0" in "${WinText}" | ${GUIMAP_60}
| | ... | ${GUIMAP}
| | ${GUIMAP}= | Set Variable If | "6.1" in "${WinText}" | ${GUIMAP_61}
| | ... | ${GUIMAP}
| | Run Keyword If | ${GUIMAP}== None | Fail | Calculator version not supported: ${WinText}
| | Set Suite Variable | ${GUIMAP}
| | ${MENUMAP}= | Set Variable If | "5.1" in "${WinText}" | ${GUIMAP_51}
| | ${MENUMAP}= | Set Variable If | "6.0" in "${WinText}" | ${GUIMAP_60}
| | ... | ${MENUMAP}
| | ${MENUMAP}= | Set Variable If | "6.1" in "${WinText}" | ${GUIMAP_61}
| | ... | ${MENUMAP}
| | Set Suite Variable | ${MENUMAP}
| | Control Click | About Calculator | Version | Button1
| Get Answer
| | Select Calculator menu Item | Edit Copy
| | ${Answer}= | Clip Get
| | [Return] | ${Answer}
这个关键字产生错误的原因是什么?
先谢谢你。
解决方案
"字典不包含关键的'视图科学'"应该是相当不言自明的。你想用钥匙 "View Scientific"
作为字典的键,而那个字典没有那个键。
在你的情况下,你有一个名为字典 ${MENUMAP}
显然是这样 不是 有钥匙 "View Scientific"
.您需要弄清楚为什么您的地图缺少此密钥。一个简单的事情是记录字典,它会告诉你它有什么键。
不隶属于 StackOverflow