문제

현재 AutoIt 라이브러리 로봇 프레임 워크 그래서 나는 전형적인"내 첫 번째 "로봇 GUI 테스트를하고 계산기를 테스트하고 있습니다!불행히도 내 코드는 오류를 생성합니다. Dictionary does not contain key 'View Scientific'..이것은 Start Calculator 키워드에서 발생합니다. Calculator 메뉴 항목 선택 을 호출 할 때마다 오류가 발생합니다.

*** 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'이 포함되어 있지 않습니다."는 꽤 자명해야합니다.KEY "View Scientific"를 사전의 키로 사용하려고하고 있으며 그 사전은 그 키가 없습니다.

귀하의 경우에 이 아닌 not 키를 갖는 사전을 가지고 있습니다.지도 가이 키가 누락 된 이유를 알아 내야합니다.할 일을하는 간단한 일은 사전을 기록하는 것입니다. 이는 어떤 키가 있는지 알려줍니다.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top