Пример #1
0
 def wait_until_css(self, selector, timeout=30):
     node = self.find_by_css(selector)
     elapsed = 0
     while not node:
         if elapsed > timeout:
             return None
         Utils.wait(1000)
         elapsed += 1
         node = self.find_by_css(selector)
     return node
Пример #2
0
 def wait_until_xpath(self, xpath, timeout=30):
     node = self.find_by_xpath(xpath)
     elapsed = 0
     while not node:
         if elapsed > timeout:
             return None
         Utils.wait(1000)
         elapsed += 1
         node = self.find_by_xpath(xpath)
     return node
Пример #3
0
    def search(self, region_letter, number):
        if self.__login():
            print('**enter number and region')
            region = self.robot.wait_until_xpath("/html/body/div[1]/div[4]/div[1]/div/div[2]/div[1]/div/select")
            region_options = region.find_all_by_css('option')
            for o in region_options:
                if o.get_value() == region_letter:
                    o.select_option()

            #
            input_number = self.robot.find_by_xpath("/html/body/div[1]/div[4]/div[1]/div/div[2]/div[1]/input")
            input_number.set_value(number)
            #     print(input_number.get_value())
            print('set number')
            input_number.enter()
            print('before wait')
            Utils.wait(2001)

            print('8888888888')
            result = {}
            print('before find')
            profilename = self.robot.wait_until_css('div.ProfileName')
            print('after find ', profilename.get_attribute('class'))
            if profilename:
                print('a')
                print('b')
                profilename_box = profilename.find_by_css('div')
                print('cc')
                profilename_text = profilename_box.get_text()
                print('after tex pro')
                print(1111, profilename_text)
                if 'is not yet available' in profilename_text:
                    print('b')
                    result['profileName'] = 'is not yet available'
                else:
                    print('c')
                    result['profileName'] = profilename_text
                    list_info = self.robot.find_by_css('div.ProfileDetails.ProfileContainer')
                    if list_info:
                        number_info = self.robot.find_by_xpath('/div[1]/div/div[2]')
                        if number_info:
                            number = number_info.find_by_xpath('/div[1]')
                            operator = number_info.find_by_xpath('/div[2]')

                            if number:
                                result['number'] = number
                            if operator:
                                result['operator'] = operator

                        location = self.robot.find_by_xpath('/div[2]/a/div[2]/div')
                        if location:
                            result['location'] = location
            else:
                print('fffffff')


            print('***', result)
            with open(BASE_APP_PATH + '/modules/truecaller/v_1_0/storage/' + self.proccess_id + '.pkl', 'wb') as f:
                pickle.dump(result, f)
                f.close()
            Utils.wait(3000)
            print('eeeeeeeeeeeeeeeeeeeeeeeeeeeend')
            sys.exit()