<练手1>(python+selenium)随机生成搜索码,搜索,并在搜索栏匹配结果进行输出
2017-03-03 13:26
465 查看
字典管理模块,想进行生成随机字典码,搜索,匹配结果并输出的功能
代码
总结:
写得乱七八糟了,希望后期没有那么辣鸡的时候知道如何修改
代码
#搜索功能 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"字典管理:搜索功能测试完毕")
总结:
写得乱七八糟了,希望后期没有那么辣鸡的时候知道如何修改
相关文章推荐
- 第九周实验报告任务 1 定义Time类中的<<和>>运算符重载,实现时间的输入输出,改造原程序中对运算结果显示方式,使程序读起来更自然。
- <开发笔记>搭建LAMP服务器及使用FFMPEG进行切片、生成m3u8文件
- python生成CMPL16类型随机定标测试数据并输出到文件
- 搜索结果按匹配字段进行排序
- 搜索结果按匹配字段进行排序
- 第九周实验报告 任务2 定义Complex类中的<<和>>运算符的重载,实现输入和输出,改造原程序中对运算结果显示方式,使程序读起来更自然。
- Python练手之根据前序和中序&根据中序和后序重建二叉树,输出前序、中序和后序遍历结果
- <Python高级全栈开发工程师-1>学习过程笔记【181-184】正则表达式 <特殊字符><函数>
- <1>python学习笔记——字符串操作
- <<编程珠玑>> 生成随机文本
- 练手python_随机生成200个获奖码
- python_selenium单元测试+自动生成测试结果
- python 生成满二叉树并进行深度优先搜索和宽度优先搜索
- 编程产生一个int数组,长度为30,并向其中随机插入1-30,并且不能重复输出数组。实现一个冒泡排序算法对其进行排序,输出排序结果
- selenium+Python自动化测试 结果输出
- Python+Selenium进行UI自动化测试项目中,常用的小技巧4:日志打印,longging模块(控制台和文件同时输出)
- <hdu - 3999> The order of a Tree 水题 之 二叉搜索的数的先序输出
- Python+selenium实现图片网站搜索后下载搜索结果的全部照片
- 第七周 OJ总结<2>-输入两个整数,进行四则运算并输出结果