2016-08-18 26 views
0

我想重構我的測試從Python 2.7到Python 3.5。在這一刻,我已經有了elementium lib的問題。這個lib有什麼問題?Python3和elementium

return SeElements(
    self.browser, context=self, fn=lambda context: [context.items[i]], config=self.config) 

錯誤:

File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/elementium/drivers/se.py", line 96, in <lambda> 
    self.browser, context=self, fn=lambda context: [context.items[i]], 
TypeError: list indices must be integers or slices, not str 
+0

96行:https://github.com/actmd/elementium/blob/master/elementium/drivers/se.py – Macio

回答

0

此刻你是一個價值i傳遞給items列表。這個錯誤非常具有描述性,它抱怨我的值是一個字符串,而不是一個整數。要通過其索引訪問列表元素,您必須提供整數。

你能分享一下你定義的代碼i嗎?也許你只需要調用int()函數呢?