【问题标题】:Looping through List into Dictionary in order to tap element in appium将列表循环到字典中以点击 appium 中的元素
【发布时间】:2015-05-04 09:58:46
【问题描述】:

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

| 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)

我不知道为什么。

【问题讨论】:

    标签: python appium robotframework


    【解决方案1】:

    您对“输入密码”的调用是将列表作为列表的实例传入。您需要使用 @ 指定它来展开它

    | | Enter the passcode | @{Passcode}
    

    【讨论】:

      猜你喜欢
      • 2020-05-10
      • 2021-09-23
      • 1970-01-01
      • 1970-01-01
      • 2019-03-10
      • 2014-07-06
      • 2016-01-05
      • 1970-01-01
      相关资源
      最近更新 更多