Question

Je joue actuellement avec le AutoIt bibliothèque pour Cadre de robot, je fais donc le test typique de « mon premier » interface graphique de robot et je teste la calculatrice !Malheureusement, mon code ci-dessous génère l'erreur : Dictionary does not contain key 'View Scientific'..Cela se produit dans le Démarrer la calculatrice mot-clé.Il semble que chaque fois que j'appelle Sélectionnez l'élément de menu de la calculatrice J'obtiens une erreur.

*** 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}

Quelle est la raison pour laquelle ce mot clé génère des erreurs ?

Merci d'avance.

Était-ce utile?

La solution

"Le dictionnaire ne contient pas la clé 'View Scientific'" devrait être assez explicite.Vous essayez d'utiliser la clé "View Scientific" comme clé d'un dictionnaire, et ce dictionnaire n'a pas cette clé.

Dans votre cas, vous disposez d'un dictionnaire nommé ${MENUMAP} c'est apparemment le cas pas avoir la clé "View Scientific".Vous devez comprendre pourquoi votre carte ne dispose pas de cette clé.Une chose simple à faire est d’enregistrer le dictionnaire, qui vous indiquera de quelles clés il dispose.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top