#encoding=utf-8
import unittest
import time
import chardet
from selenium import webdriver class VisitSogouByIE(unittest.TestCase): def setUp(self):
#启动IE浏览器
#self.driver = webdriver.Firefox(executable_path = "e:\\geckodriver")
self.driver = webdriver.Ie(executable_path = "e:\\IEDriverServer") def test_operateCheckBox(self):
url = "http://127.0.0.1/test_checkbox.html"
# 访问自定义的html网页
self.driver.get(url)
# 使用xpath定位获取value属性值为'berry'的input元素对象,也就是“草莓”选项
berryCheckBox = self.driver.find_element_by_xpath("//input[@value='berry']")
# 点击选择“草莓”选项
berryCheckBox.click()
# 断言“草莓”复选框被成功选中
self.assertTrue(berryCheckBox.is_selected(), u"草莓复选框未被选中!")
if berryCheckBox.is_selected():
# 如果“草莓”复选框被成功选中,再次点击取消选中
berryCheckBox.click()
# 断言“草莓”复选框处于未选中状态
self.assertFalse(berryCheckBox.is_selected())
# 查找所有name属性值为“fruit”的复选框元素对象,并存放在checkBoxList列表中
checkBoxList = self.driver.find_elements_by_xpath("//input[@name='fruit']")
# 遍历遍历checkBoxList列表中的所有复选框元素,让全部复选框处于被选中状态
for box in checkBoxList:
if not box.is_selected():
box.click()
time.sleep(3) def tearDown(self):
# 退出IE浏览器
self.driver.quit() if __name__ == '__main__':
unittest.main()

最新文章

  1. [moka同学笔记]六、Yii2.0课程笔记(魏曦老师教程)[徽章气泡]
  2. jQuery入门教程
  3. 利用mysql_multi来管理多实例:
  4. Android系统Surface机制的SurfaceFlinger服务渲染应用程序UI的过程分析
  5. ABAP 承运路单
  6. 点击cell弹出一个日期选择器
  7. VC++中几种字符标志的解释
  8. 4月1日学习笔记(CSS基础)
  9. LabVIEW系列——拍振现象重现
  10. Children of the Candy Corn
  11. []: secureCRT连接ubuntu问题- The remote system refused the connection
  12. GO中的数组切片
  13. c++ 回调函数使用
  14. 『性能』ServiceStack.Redis 和 StackExchange.Redis 性能比较
  15. Data Lake Analytics + OSS数据文件格式处理大全
  16. Java中常用类(包装类扩展知识)
  17. Redhat 下 XAMPP 安装和部署 DVWA 教程
  18. PHP源码编译安装
  19. django博客项目-设置django为中文语言
  20. 日志收集以及分析:Splunk

热门文章

  1. pixhawk在linux(ubuntu16.04)下的开发环境搭建和源码编译
  2. 多线程-Thread-Runnable
  3. elasticsearch查询方式
  4. IOS制作纯色背景
  5. String | StringBuffer | StringBuilder 比较
  6. Mysql安装报错解决办法
  7. BLL-IDAL-DAL的关系
  8. LINQ 基础语句
  9. SAP标准培训课程C4C10学习笔记(二)第二单元
  10. 如何从Ubuntu 16.04 LTS升级到Ubuntu 18.04 LTS