Python+selenium自动化测试:报错:TypeError: 'WebElement' object is not iterable
代码:
# -*- coding: utf-8 -*-from selenium import webdriverfrom selenium.webdriver.common.by import Byfrom selenium.webdriver.common.keys import Keysfrom selenium.webdriver.support.ui import Selectfrom selenium.common.exceptions import NoSuchElementExceptionfrom selenium.common.exceptions import NoAlertPresentExceptionimport unittest, time, re class KeywordsAnalyse(unittest.TestCase): driver=webdriver.Chrome("E:\chromedriver_win32\chromedriver.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报错TypeError: ‘User‘ object is not iterable
Python报错TypeError: 'User' object is not iterable 原因 User对象是不可迭代的,我这里是因为User并不是list,所以是不可迭代的,所以不使用迭代即 ...
- 个人报错TypeError: ‘type‘ object is not iterable
django报错 'type' object is not iterable,个人报错原因解析 E:\django_project\my_blog\article\models.py changed, ...
- python 多进程multiprocessing进程池pool tensorflow-yolov3 报错TypeError: 'ApplyResult' object is not iterable
首先,代码结构它长这样: 可每次调用线程池进行识别时,就会报如下错误: D:\20191031_tensorflow_yolov3\python\python.exe D:/20191031_tens ...
- Python报错TypeError: 'str' object is not callable
原文:http://blog.sina.com.cn/s/blog_71f3890901017rsh.html Python报错TypeError: 'str' object is not calla ...
- python nonetype object is not_python报错TypeError: ‘NoneType‘ object is not subscriptable的解决方法...
发现问题 写python的时候出现了这个错,然后网上的教程的解决方案几乎都是--"重新定义下这个变量",看的我一脸懵逼 后来发现原来是我把return None的方法赋给了变量,之 ...
- Python----方法返回None值报错 TypeError NoneType object is not callable
转载请声明,本文来自:https://blog.csdn.net/shijianduan1/article/details/106415395 相信很多小伙伴, 在遇到报错的时候,直接搜索报错内容, ...
- python打开文件报错无效序列_解决Python 写文件报错TypeError的问题
处理上传的文件: f1 = request.FILES['pic'] fname = '%s/%s' % (settings.MEDIA_ROOT, f1.name) with open(fname, ...
- Python关于None的报错:'NoneType' object is not iterable和cannot unpack non-iterable NoneType object
文章目录 一.TypeError:'NoneType' object is not iterable(类型错误:'NoneType'对象不是可迭代的) 二.TypeError: cannot unpa ...
- python报错:TypeError: 'str' object is not callable
这个问题遇到好多次了,这次记录一下, 问题重现 代码仅保留最重要的: # summaries 是一个集合 # 求和并打印 result = 0 for str in summaries: result ...
最新文章
- android 图片过滤,android 图片转为bitmap,黑白镜过滤
- Linux下的进程概论与编程二(进程控制)
- 摇滚bono_Java比以往任何时候都摇滚
- 长沙中职英语计算机等级考试查询,湖南省中等职业教育公共基础课达标训练英语291-300...
- SharePoint 2013 添加Ribbon菜单
- p值小于0.05拒绝还是接受_干货:关乎你的实验成败,0.05这个值不容小觑!
- python什么为假_Python返回真假值(True or False)小技巧
- 第三章:顺序结构程序设计(练习题)
- 鸿蒙DevEco Studio 无法下载Gradle问题
- 嘉曼服饰上市破发,大跌16%:公司市值37亿 刘溦家族色彩浓厚
- 原来小米手机这么好用,这4大功能,各个都是黑科技,厉害了
- SPSS多元线性回归残差分析的基本方法
- OFDM和F-OFDM的功率谱与峰均功率比仿真
- 富士康计算机类笔试题,明天去富士康面试,还要笔试英语智力题?这个英语智力题,难不难,有没有从富士康面试完毕的大虾们,都是什么类型的题?(本人英语不好),比较着急,再次给回答人50分!...
- 实现僵尸跑酷游戏的 UGUI 实践
- SCOM2012升级授权License
- Mac用户学Python——Day3调用飞书webhook接口
- 【转载】SAP中与物料BOM有关的表关联
- 树莓派-使用Windows远程桌面连接RPI4
- 利用HttpClient抓取话费详单等信息