将List循环到Dictionary中以便在appium中挖掘元素

时间:2015-03-03 16:37:52

标签: python appium robotframework

我有这个代码:基本上我试图遍历这个键盘字典,并根据传入的变量,点击相应的密码键。

| Create a new Passcode
| | [Documentation] | test
| | @{Passcode} = | Create List | 1 | 2 | 3 | 4
| | Enter the passcode | ${Passcode}


| Enter the passcode
| | [arguments] |  @{Keys}
| | ${keypadDictionary} | Create Dictionary
| | ... | 0         | keypad-zero
| | ... | 1         | keypad-one
| | ... | 2         | keypad-two
| | ... | 3         | keypad-three
| | ... | 4         | keypad-four
| | ... | 5         | keypad-five
| | ... | 6         | keypad-six
| | ... | 7         | keypad-seven
| | ... | 8         | keypad-eight
| | ... | 9         | keypad-nine
| | wait for screen to contain element | ${Passcode screen}
| | :FOR | ${Key} | IN | @{Keys}
| | | Tap | ${keypadDictionary['${Key}']}

我收到此错误:

Resolving variable '${keypadDictionary['[u'1', u'2', u'3', u'4']']}' failed: SyntaxError:     
invalid syntax (<string>, line 1)

我不明白为什么。

1 个答案:

答案 0 :(得分:2)

您打电话给&#39;输入密码&#39;将列表作为列表的实例传递。您需要使用@来指定它以扩展它

| | Enter the passcode | @{Passcode}
相关问题