zoukankan      html  css  js  c++  java
  • 获取ul下面最后一个li或ul中有多少个li

    获取ul下面最后一个li或ul中有多少个li

    先获取ul的对象,再通过这个对象获取li的list用for循环取值text之类的

      def set_city(self, base_info):
            qualified_city = base_info['qualified_city_input']
            if '全国' in qualified_city.keys():
                self.get_element('china_checkbox').click()
            else:
                self.get_element('qualified_city_unfold_button').click()  # 点击城市按钮
                provinces = self.get_element_list('places_checkbox')  # 获取全部城市                                  知识点
                for province in provinces:
                    province_name = province.find_element_by_css_selector('.ivu-tree-title').text  # 获取城市的名字
                    # print(province_name)
                    if province_name in qualified_city.keys():
                        citys = qualified_city[province_name]
                        # print(citys)
                        if not citys:
                            province.find_element_by_css_selector('.ivu-checkbox-input').click()  # 知识点
                        else:
                            province.find_element_by_css_selector('.ivu-tree-arrow').click()
                            city_eles = province.find_elements_by_css_selector('li > ul')
                            for city_ele in city_eles:
                                city_name = city_ele.find_element_by_css_selector('.ivu-tree-title').text
                                if city_name in citys:
                                    print(city_name)
                                    city_ele.find_element_by_css_selector('.ivu-checkbox-input').click()
  • 相关阅读:
    vs与linux的交叉编译环境搭建
    layui框架部分功能介绍
    谷歌添加百度翻译提示Google已将百度翻译标记为恶意程序并阻止安装,怎么办
    七,JOBC数据库编程
    mysql数据库
    六,IO系统
    五,图形界面编程
    四,集合框架
    三,反射类
    二,常用类
  • 原文地址:https://www.cnblogs.com/lvchengda/p/12627104.html
Copyright © 2011-2022 走看看