1
我有一個包含三個webelement對象的硒webelement列表。我想要使用for循環獲取每個元素的索引。我怎麼能在Python中做到這一點?Python:如何迭代硒webelement列表並獲取索引?
目前正在做的是這樣的:
countries=Select(self.driver.find_element_by_xpath('//[@id="id_country"]')).options
for index, value in countries:
print index
,但它給我的錯誤
TypeError: 'WebElement' object is not iterable
,你可以分享你實際上已經試過嗎? – sumit
我已添加更多解釋 –