python循环嵌套遍历前后关联的select下拉框
来源:互联网 发布:融资租赁软件 编辑:程序博客网 时间:2024/05/29 11:15
select = driver.find_element_by_id("id_num")
options_list = select.find_elements_by_tag_name("option")
time.sleep(2)
count_option = 0
for option in options_list:
value = option.get_attribute("value")
text = option.text
filename = text.encode("utf-8")+".txt"
f = open(unicode("D:\\temp\\123_loop\\" + filename, "utf-8"), "w+")
# print "Value is: " + value
# print "Text is:" + text
# print "count_option" + str(count_option)
driver.find_element_by_id("id_num").find_elements_by_tag_name("option")[count_option].click()
count_option += 1
time.sleep(4)
select2 = driver.find_element_by_id("id_num2")
options_list2 = select2.find_elements_by_tag_name("option")
count = 0
for option2 in options_list2:
value2 = option2.get_attribute("value")
text2 = [option2.text+'\n']
# print "Value2 is: " + value2
# print "Text2 is:" + text2
driver.find_element_by_id("id_num2").find_elements_by_tag_name("option")[count].click()
time.sleep(3)
f.writelines(text2[0].encode("utf-8"))
count += 1
f.writelines('\n数据总数:'+str(count))
f.close()
options_list = select.find_elements_by_tag_name("option")
time.sleep(2)
count_option = 0
for option in options_list:
value = option.get_attribute("value")
text = option.text
filename = text.encode("utf-8")+".txt"
f = open(unicode("D:\\temp\\123_loop\\" + filename, "utf-8"), "w+")
# print "Value is: " + value
# print "Text is:" + text
# print "count_option" + str(count_option)
driver.find_element_by_id("id_num").find_elements_by_tag_name("option")[count_option].click()
count_option += 1
time.sleep(4)
select2 = driver.find_element_by_id("id_num2")
options_list2 = select2.find_elements_by_tag_name("option")
count = 0
for option2 in options_list2:
value2 = option2.get_attribute("value")
text2 = [option2.text+'\n']
# print "Value2 is: " + value2
# print "Text2 is:" + text2
driver.find_element_by_id("id_num2").find_elements_by_tag_name("option")[count].click()
time.sleep(3)
f.writelines(text2[0].encode("utf-8"))
count += 1
f.writelines('\n数据总数:'+str(count))
f.close()
0 0
- python循环嵌套遍历前后关联的select下拉框
- selenium+python 遍历select下拉框获取value值
- python的循环嵌套
- js/jquery遍历select下拉框的值
- JQuery遍历select下拉选项的方法
- Python+selenium 非select类型的下拉框选择
- sql 嵌套select与关联select
- Python中嵌套list的遍历
- python嵌套dict的深度遍历合并
- python嵌套字典的递归遍历
- python列表的嵌套,嵌套循环,numpy中的数组
- select下拉框的绑定
- 漂亮的SELECT下拉框
- 下拉框的绑定<select>
- Python--循环嵌套语法
- Python菜鸟--循环嵌套
- Python 循环嵌套
- Python 循环嵌套
- Mac 配置环境变量的方法
- 常用框架组合
- 数组分割
- maven学习
- Qt常用类型总结(转)
- python循环嵌套遍历前后关联的select下拉框
- PLDA简介
- 5.Java面向对象
- 金融词汇
- 最好用的笔记软件AM-NoteBook 和 AllMyNotes
- 贪心算法解决背包问题
- 微信公众帐号开发-消息的接收与响应
- jstack和线程dump分析
- hiho #1033 : 交错和