• 获取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()
  • 相关阅读:
    Golang中用==判断是否相等
    reactnative项目运行失败的解决方法
    使用Redis实现分布式锁
    Zksnarks笔记: from programe to QAP
    [loj6696]复读机 加强版
    [loj3561]The short shank; Redemption
    [atARC135D]Add to Square
    [atARC134F]Flipping Coins
    [loj2157]避雷针
    [loj3653]抽奖机
  • 原文地址:https://www.cnblogs.com/lvchengda/p/12627104.html
Copyright © 2020-2023  润新知