日常使用selenium的時候,會遇到報錯,以下是經常遇到的情況,經過實踐後發現自己遇到的情況在參考網上的文章下可解決這個問題,於是記錄下來。
出現索引錯誤,以下僅僅是舉個例子。
通過class查找相應的頁面元素,代碼如下
el5 = driver.find_element_by_class_name("android.widget.EditText")[1]
在運行以上代碼的時候,報了一個這樣的bug
’WebElement’ object does not support indexing
解決方案是
el5 = driver.find_elements_by_class_name("android.widget.EditText")[1]
把find_element 改爲find_elements
參考來源:
https://blog.csdn.net/dangsh_/article/details/80507256