<练手1>(python+selenium)随机生成搜索码,搜索,并在搜索栏匹配结果进行输出
来源:互联网 发布:大连纬创软件 编辑:程序博客网 时间:2024/06/14 00:17
字典管理模块,想进行生成随机字典码,搜索,匹配结果并输出的功能
代码
#搜索功能 number1=random.randint(0,20) #生成整数随机字典码 number="%02d"%number1 #如果是个位数,十位自动补0 print(u"搜索的随机数为:",number) driver.find_element_by_id("SearchKey").send_keys(number) driver.find_element_by_id("btnSearch").click()#下拉框选择 sel=driver.find_element_by_id("s_typeId") Select(sel).select_by_value("2") lists=driver.find_element_by_id("list").find_elements_by_xpath("//tbody/tr[@tabindex='-1']/td[@aria-describedby='list_GbCode']") lists2=driver.find_element_by_id("list").find_elements_by_xpath("//tbody/tr[@tabindex='-1']/td[@aria-describedby='list_TypeName'] print(u"搜索结果条数:",len(lists)) if len(lists)!=0:#精确查询 for list in lists: if list.get_attribute('title') !=str(number): print(u"搜索结果不正确") print(list.get_attribute('title')) else: print(u"搜索结果正确")#精确查询#模糊查询 for list in lists: if str(number) in list.get_attribute('title'): for list2 in lists2: print(u"搜索字典码结果正确") if list2.get_attribute('title')!="政治面貌代码": print(u"字典类型不匹配",list2.get_attribute('title')) else: print(u"搜索字典类型结果正确") else: print(u"字典代码不正确,此项字典代码为:",list.get_attribute('title'))#模糊查询 else: print(u"搜索结果为空") print(u"字典管理:搜索功能测试完毕")
总结:
写得乱七八糟了,希望后期没有那么辣鸡的时候知道如何修改
0 0
- <练手1>(python+selenium)随机生成搜索码,搜索,并在搜索栏匹配结果进行输出
- 搜索结果按匹配字段进行排序
- python使用get在百度搜索并保存第一页搜索结果
- python 生成满二叉树并进行深度优先搜索和宽度优先搜索
- Python+selenium实现图片网站搜索后下载搜索结果的全部照片
- selenium验证模糊搜索结果是否正确
- python抓取百度搜索结果
- Python 获取Twitter搜索结果
- python 爬虫百度搜索结果
- python抓取google搜索结果
- Android学习笔记之百度地图(周边检索poiSearchNearBy跳转页面并输出搜索结果)
- python字符串搜索与匹配
- 搜索匹配
- WEB版OA发邮件,在通讯录里输入姓名进行搜索,无搜索结果
- Selenium打开浏览器并搜索关键字
- Selenium IDE录制的百度搜索并点击结果测试用例回放报错
- 自建搜索帮助,并删除重复搜索结果
- 如何先搜索文件然后在文件中搜索具体内容进行输出?
- C++ 对象的内存布局
- A Beginner's Guide To Understanding Convolutional Neural Networks
- Linux下Tomcat+jdk的安装配置
- C++ map用法
- 深入浅出Redis-Spring整合Redis
- <练手1>(python+selenium)随机生成搜索码,搜索,并在搜索栏匹配结果进行输出
- 【Python】学习笔记——-20、Web开发
- 【Oracle】RAC11gR2Grid启动顺序及启动故障诊断思路
- 常用工具类代码段
- 关于函数是否能改变值
- 三种方法使图片变成灰色(前端技术)
- [故障公告] 13-52-14-03,访问量突增,博客web服务器CPU 100%
- Mac如何根据eclipse安装Tomcat
- 高性能高可用服务器架构实践(二)