我是靠谱客的博主 满意钢铁侠,这篇文章主要介绍Python+selenium自动化测试:报错:TypeError: 'WebElement' object is not iterable,现在分享给大家,希望可以做个参考。
代码:
# -*- coding: utf-8 -*-
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.ui import Select
from selenium.common.exceptions import NoSuchElementException
from selenium.common.exceptions import NoAlertPresentException
import unittest, time, re
class KeywordsAnalyse(unittest.TestCase):
driver=webdriver.Chrome("E:chromedriver_win32chromedriver.exe")
driver.get("https://。。。。。。/oldriver/login")
driver.find_element_by_id("username").clear()
driver.find_element_by_id("username").send_keys("")
driver.find_element_by_id("password").clear()
driver.find_element_by_id("password").send_keys("000000")
driver.find_element_by_xpath(".//*[@id='loginForm']/input").click()
driver.find_element_by_xpath(".//*[@id='side-menu']/li[4]/a").click()
driver.find_element_by_xpath(".//*[@id='keywords']").send_keys("fidget spinner")
select=Select(driver.find_element_by_id("category"))
all_options=driver.find_element_by_id("category")
for option in all_options:
print("")
driver.find_element_by_id("btnSubmit").click()
报道错误:TypeError: 'WebElement' object is not iterable
修改:
all_options=driver.find_element_by_id("category")改为
all_options=driver.find_elements_by_id("category")
转载于:https://www.cnblogs.com/yangcl0212/p/6956290.html
最后
以上就是满意钢铁侠最近收集整理的关于Python+selenium自动化测试:报错:TypeError: 'WebElement' object is not iterable的全部内容,更多相关Python+selenium自动化测试:报错:TypeError:内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复