'WebElement' object is not iterable
checkbox.html源码:
<html>
<head>
<meta http-equiv="content-type" content="text/html;charset=utf-8" />
<title>Checkbox</title>
<script type="text/javascript" async="" src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<link href="http://netdna.bootstrapcdn.com/twitter-bootstrap/2.3.2/css/bootstrap-combined.min.css" rel="stylesheet" />
<script src="http://netdna.bootstrapcdn.com/twitter-bootstrap/2.3.2/js/bootstrap.min.js"></script>
</head>
<body>
<h3>checkbox</h3>
<div class="well">
<form class="form-horizontal">
<div class="control-group">
<label class="control-label" for="c1">checkbox1</label>
<div class="controls">
<input type="checkbox" id="c1" />
</div>
</div>
<div class="control-group">
<label class="control-label" for="c2">checkbox2</label>
<div class="controls">
<input type="checkbox" id="c2" />
</div>
</div>
<div class="control-group">
<label class="control-label" for="c3">checkbox3</label>
<div class="controls">
<input type="checkbox" id="c3" />
</div>
</div>
<div class="control-group">
<label class="control-label" for="r">radio</label>
<div class="controls">
<input type="radio" id="r" />
</div>
</div>
</form>
</div>
</body>
</html>
Python代码:
#coding=utf-8 from selenium import webdriver
import time
import os dr = webdriver.Firefox()
file_path = 'file:///' + os.path.abspath('checkbox.html')
dr.get(file_path) # 选择所有的checkbox并全部勾上 checkboxes = dr.find_element_by_css_selector('input[type=checkbox]')
for check in checkboxes:
check.click()
time.sleep(1) # 打印当前页面上有多少个checkbox dr.quit()
报错内容:TypeError: 'WebElement' object is not iterable
解决办法:
checkboxes = dr.find_element_by_css_selector('input[type=checkbox]')
改为:
checkboxes = dr.find_elements_by_css_selector('input[type=checkbox]')
'WebElement' object is not iterable的更多相关文章
- DJANGO问题--Error: ‘ManyRelatedManager’ object is not iterable
http://www.itblah.com/django-error-manyrelatedmanager-object-iterable/ Django: Error: ‘ManyRelatedMa ...
- 'ManyRelatedManager' object is not iterable
先看下面的代码: class Worker(models.Model): departments = moels.ManyToManyField(Department, verbose_name=u& ...
- 'NoneType' object is not iterable
"TypeError: 'NoneType' object is not iterable" 一般是返回值为None同时赋值给了多个变量
- appium 与 selenium python解决python 'WebElement' object does not support indexing 报错问题问题
再用selenium编写测试脚本时,发现出现python 'WebElement' object does not support indexing 报错问题问题,再找一些解决方法时,发现Appium ...
- Python问题:'Nonetype' object is not iterable
参考链接:http://blog.csdn.net/dataspark/article/details/9953225 [解析] 这个错误提示一般发生在将None赋给多个值时. [案例] 定义了如下的 ...
- AttributeError: 'WebElement' object has no attribute 'send_keys'
这个是没问题的代码:用来打开谷歌搜索cheese并退出 from selenium import webdriver from selenium.common.exceptions import Ti ...
- TypeError: 'ExcelData' object is not iterable
今天写了个测试的代码,结果在执行test_register.py文件在调用readexcle.py的时候一直报错TypeError: 'ExcelData' object is not iterabl ...
- python TypeError: 'NoneType' object is not iterable
list(set(map(lambda tp_id : tp_id if not ('#' in tp_id) and len(tp_id.strip().replace('\n', '')) > ...
- TypeError: 'TestCase' object is not iterable
这个异常呢其实是因为我对list没有足够熟悉 我一开始很疑惑,明明已经正确返回testcase对象了呀,为啥会报TypeError: 'TestCase' object is not iterable ...
随机推荐
- Oracle创建数据库链接
**********创建数据库链接******************create public database link link_gzzl connect to system identifie ...
- spark-submit 提交Application
在spark1.0中推出spark-submit来统一提交applicaiton ./bin/spark-submit \ --class <main-class> --master &l ...
- 修改oracle数据库默认时间格式
原创作品,允许转载,转载时请务必以超链接形式标明文章 原始出处 .作者信息和本声明.否则将追究法律责任.http://ccchencheng.blog.51cto.com/2419062/929695 ...
- shell for的使用
好久没写shell了,花了半个小时才写对,不常用果然不够熟悉,以后还是得每天花半个小时写写shell #!/bin/sh #set -x p="/" cd $p echo $(pw ...
- thymeleaf的使用
1.导包 <dependency> <groupId>org.springframework.boot</groupId> <artifactId>sp ...
- as3 typeof 对象类型与返回结果对照表 is as
is 和as 运算符使用很广泛.is 用来判断一个对象是否属于一种类型,返回布尔值,true 代表属于,false 表示不属于.使用格式如下:trace (9 is Number); //输出:tru ...
- SRC是在本位置显示:source的缩写,源的意思 HREF是点击后连接的目标:HyperlinkReference,超链接引用
SRC是在本位置显示:source的缩写,源的意思HREF是点击后连接的目标:HyperlinkReference,超链接引用
- hibernate注解主键生成策略
Id生成策略: @GeneratedValue,JPA通用策略生成器 . JPA提供的四种标准用法为TABLE,SEQUENCE,IDENTITY,AUTO. TABLE:使用一个特定的数据库表格来 ...
- MySQLReport
简介: MySQLReport 一.安装 shell > yum -y install mysqlreport perl-DBD-MySQL 二.使用 shell > mysqlrepor ...
- How to Pronounce the Word ‘TO’
How to Pronounce the Word ‘TO’ Share Tweet Share Tagged With: TO Reduction Study the TO reduction. ...