|  | @@ -32,7 +32,7 @@ class CreateAdPlan():
 | 
	
		
			
				|  |  |              title_.send_keys(Keys.BACKSPACE)
 | 
	
		
			
				|  |  |          title_.click()
 | 
	
		
			
				|  |  |          time.sleep(0.1)
 | 
	
		
			
				|  |  | -        title_.send_keys(self.task['title'])
 | 
	
		
			
				|  |  | +        title_.send_keys(self.task['title'].replace(' ', '')[:29])
 | 
	
		
			
				|  |  |          title_.send_keys(Keys.RETURN)
 | 
	
		
			
				|  |  |          time.sleep(random.uniform(0.1, 0.2))
 | 
	
		
			
				|  |  |  
 | 
	
	
		
			
				|  | @@ -65,10 +65,17 @@ class CreateAdPlan():
 | 
	
		
			
				|  |  |                          ''')
 | 
	
		
			
				|  |  |          WebDriverWait(self.driver, 10).until(
 | 
	
		
			
				|  |  |              lambda driver: self.driver.find_element_by_css_selector('#PRODUCTTYPE_WECHAT'))
 | 
	
		
			
				|  |  | +        # 设置公众号名字
 | 
	
		
			
				|  |  | +        for i in range(30):
 | 
	
		
			
				|  |  | +            self.driver.find_element_by_xpath('//*[@id="test_plan_name"]/input').send_keys(Keys.BACKSPACE)
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        self.driver.find_element_by_xpath('//*[@id="test_plan_name"]/input').send_keys(
 | 
	
		
			
				|  |  | +            self.task['title'].replace(' ', '')[:29])
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |          # 推广公众号
 | 
	
		
			
				|  |  |          wechat_gg = self.driver.find_element_by_css_selector('#PRODUCTTYPE_WECHAT')
 | 
	
		
			
				|  |  |          wechat_gg.click()
 | 
	
		
			
				|  |  | -        localtion = self.task['localtion']
 | 
	
		
			
				|  |  | +        localtion = self.task['plan_base'][1]
 | 
	
		
			
				|  |  |          if localtion == 'gzh_botoom':
 | 
	
		
			
				|  |  |              # 默认是这个选项,所以不用进行点选
 | 
	
		
			
				|  |  |              pass
 | 
	
	
		
			
				|  | @@ -134,30 +141,42 @@ class CreateAdPlan():
 | 
	
		
			
				|  |  |          time.sleep(0.1)
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      def set_ad_human_location(self):
 | 
	
		
			
				|  |  | +        # TODO:对常驻地,出差旅行,进行区分
 | 
	
		
			
				|  |  |          logging.info('设置对应人群信息-非人群包')
 | 
	
		
			
				|  |  |          WebDriverWait(self.driver, 10).until(
 | 
	
		
			
				|  |  |              lambda driver: self.driver.find_element_by_css_selector('#area_input > div > i'))
 | 
	
		
			
				|  |  |          self.driver.find_element_by_css_selector('#area_input > div > i').click()
 | 
	
		
			
				|  |  | -        if self.task['localtion'] == 'gzh_botoom':
 | 
	
		
			
				|  |  | +        if self.task['plan_base'][1] == 'gzh_botoom':
 | 
	
		
			
				|  |  |              self.driver.find_element_by_class_name('icon-3cAquX1RLZ').click()
 | 
	
		
			
				|  |  | -        if self.task['localtion'] == 'gzh_movie':
 | 
	
		
			
				|  |  | +        if self.task['plan_base'][1] == 'gzh_movie':
 | 
	
		
			
				|  |  |              citys = self.driver.find_elements_by_class_name('checkbox-1pfRMRqv-R')
 | 
	
		
			
				|  |  |              for _ in citys:
 | 
	
		
			
				|  |  |                  _.click()
 | 
	
		
			
				|  |  | -        if self.task['localtion'] == 'gzh_big_pic':
 | 
	
		
			
				|  |  | +        if self.task['plan_base'][1] == 'gzh_big_pic':
 | 
	
		
			
				|  |  |              self.driver.find_element_by_class_name('icon-3cAquX1RLZ').click()
 | 
	
		
			
				|  |  |              self.driver.find_element_by_xpath('//*[@id="bid_objective_6"]/span[1]').click()
 | 
	
		
			
				|  |  | -        if self.task['localtion'] == 'pyq':
 | 
	
		
			
				|  |  | -            self.driver.find_element_by_class_name('icon-3cAquX1RLZ').click()
 | 
	
		
			
				|  |  | +        if self.task['plan_base'][1] == 'pyq':
 | 
	
		
			
				|  |  | +            # self.driver.find_element_by_class_name('icon-3cAquX1RLZ').click()
 | 
	
		
			
				|  |  | +            citys = self.driver.find_elements_by_class_name('checkbox-1pfRMRqv-R')
 | 
	
		
			
				|  |  | +            for _ in citys:
 | 
	
		
			
				|  |  | +                _.click()
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      def set_ad_cost(self):
 | 
	
		
			
				|  |  |          # 投放计划创建
 | 
	
		
			
				|  |  |          # 广告创建
 | 
	
		
			
				|  |  | +        # TODO:出价还没有进行对应设置
 | 
	
		
			
				|  |  |          logging.info('设置对应广告花销')
 | 
	
		
			
				|  |  |          day_cost = self.driver.find_element_by_css_selector('#budget_input')
 | 
	
		
			
				|  |  |          WebDriverWait(self.driver, 10).until(lambda x: (day_cost.is_displayed() and day_cost.is_enabled()))
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -        day_cost.send_keys('101')
 | 
	
		
			
				|  |  | +        day_cost.send_keys(self.task['cost']['day_cost'])
 | 
	
		
			
				|  |  | +        time.sleep(random.uniform(0.2, 0.3))
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        bid_cost = self.driver.find_element_by_xpath('//*[@id="price_input"]')
 | 
	
		
			
				|  |  | +        for i in range(10):
 | 
	
		
			
				|  |  | +            bid_cost.send_keys(Keys.BACKSPACE)
 | 
	
		
			
				|  |  | +        time.sleep(random.uniform(0.2, 0.3))
 | 
	
		
			
				|  |  | +        bid_cost.send_keys(self.task['cost']['bid'])
 | 
	
		
			
				|  |  |          time.sleep(5)
 | 
	
		
			
				|  |  |          self.driver.find_element_by_css_selector('#target_next_step').click()
 | 
	
		
			
				|  |  |          self.driver.save_screenshot('click{}.png'.format(time.time()))
 | 
	
	
		
			
				|  | @@ -206,38 +225,58 @@ class CreateAdPlan():
 | 
	
		
			
				|  |  |          self.driver.find_element_by_xpath(
 | 
	
		
			
				|  |  |              '//*[@class="adui-button-base adui-button-primary adui-button-small"]').click()
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +    def set_ad_humam_gender(self):
 | 
	
		
			
				|  |  | +        logging.info('设置性别')
 | 
	
		
			
				|  |  | +        if self.task['human_info_parameter']['gender'] == 0:
 | 
	
		
			
				|  |  | +            self.driver.find_element_by_xpath('//*[@id="gender_"]/span[2]').click()
 | 
	
		
			
				|  |  | +        if self.task['human_info_parameter']['gender'] == 1:
 | 
	
		
			
				|  |  | +            self.driver.find_element_by_xpath('//*[@id="gender_MALE"]/span[2]').click()
 | 
	
		
			
				|  |  | +        if self.task['human_info_parameter']['gender'] == 2:
 | 
	
		
			
				|  |  | +            self.driver.find_element_by_xpath('//*[@id="gender_FEMALE"]/span[2]').click()
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |      def set_ad_age(self):
 | 
	
		
			
				|  |  | +        logging.info('设置年龄')
 | 
	
		
			
				|  |  |          age_elements = self.driver.find_elements_by_xpath('//*[@class="adui-select-selector"]')
 | 
	
		
			
				|  |  |          age_elements[0].click()
 | 
	
		
			
				|  |  |          time.sleep(0.1)
 | 
	
		
			
				|  |  | +        age_list = self.task['human_info_parameter']['age_list']
 | 
	
		
			
				|  |  | +        # TODO:66就是65以上
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |          # 256,一截,[14(17),24][25,32][33,40][41,48][49,56][57,64]
 | 
	
		
			
				|  |  | -        if self.task['age'][0] == 14:
 | 
	
		
			
				|  |  | +        if age_list[0] == 14:
 | 
	
		
			
				|  |  |              age_elements[1].click()
 | 
	
		
			
				|  |  | +            time.sleep(random.uniform(0.1, 0.2))
 | 
	
		
			
				|  |  | +            self.driver.execute_script('''
 | 
	
		
			
				|  |  | +                            document.getElementsByClassName('rc-virtual-list-holder')[0].scrollTop={};
 | 
	
		
			
				|  |  | +                            '''.format(((age_list[1] - 17) / 7) * 256))
 | 
	
		
			
				|  |  | +            self.driver.find_element_by_xpath('//*[@id="end_age_{}"]'.format(int(age_list[1]))).click()
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |          else:
 | 
	
		
			
				|  |  |              self.driver.execute_script('''
 | 
	
		
			
				|  |  |              document.getElementsByClassName('rc-virtual-list-holder')[0].scrollTop={};
 | 
	
		
			
				|  |  | -            '''.format(self.task['age'][0] - 17 / 7) * 256)
 | 
	
		
			
				|  |  | +            '''.format(((age_list[0] - 17) / 7) * 256))
 | 
	
		
			
				|  |  |              time.sleep(random.uniform(0.1, 0.2))
 | 
	
		
			
				|  |  | -            self.driver.find_element_by_xpath('//*[@id="begin_age_{}"]'.format(int(self.task['age'][0]))).click()
 | 
	
		
			
				|  |  | +            self.driver.find_element_by_xpath('//*[@id="begin_age_{}"]'.format(int(age_list[0]))).click()
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |              # 年龄---设置
 | 
	
		
			
				|  |  |              age_elements[1].click()
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | +            time.sleep(random.uniform(0.1, 0.2))
 | 
	
		
			
				|  |  |              self.driver.execute_script('''
 | 
	
		
			
				|  |  |                  document.getElementsByClassName('rc-virtual-list-holder')[0].scrollTop={};
 | 
	
		
			
				|  |  | -                '''.format(self.task['age'][0] - 17 / 7) * 256)
 | 
	
		
			
				|  |  | +                '''.format(((age_list[1] - 17) / 7) * 256))
 | 
	
		
			
				|  |  | +            time.sleep(random.uniform(0.1, 0.2))
 | 
	
		
			
				|  |  | +            self.driver.find_element_by_xpath('//*[@id="end_age_{}"]'.format(int(age_list[1]))).click()
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      def set_ad_idea(self):
 | 
	
		
			
				|  |  |          # 创意创建
 | 
	
		
			
				|  |  |          logging.info('设置创意')
 | 
	
		
			
				|  |  | -        if self.task['localtion'] == 'gzh_botoom':
 | 
	
		
			
				|  |  | +        if self.task['plan_base'][1] == 'gzh_botoom':
 | 
	
		
			
				|  |  |              self.ad_idea_action.idea_gzh_bottom()
 | 
	
		
			
				|  |  | -        if self.task['localtion'] == 'gzh_movie':
 | 
	
		
			
				|  |  | +        if self.task['plan_base'][1] == 'gzh_movie':
 | 
	
		
			
				|  |  |              self.ad_idea_action.idea_movie_gzh_movie()
 | 
	
		
			
				|  |  | -        if self.task['localtion'] == 'gzh_big_pic':
 | 
	
		
			
				|  |  | +        if self.task['plan_base'][1] == 'gzh_big_pic':
 | 
	
		
			
				|  |  |              self.ad_idea_action.idea_big_pic()
 | 
	
		
			
				|  |  | -        if self.task['localtion'] == 'pyq':
 | 
	
		
			
				|  |  | +        if self.task['plan_base'][1] == 'pyq':
 | 
	
		
			
				|  |  |              self.ad_idea_action.idea_pyq()
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |          next_button = self.driver.find_element_by_class_name('adui-button-primary')
 | 
	
	
		
			
				|  | @@ -302,10 +341,14 @@ class CreateAdPlan():
 | 
	
		
			
				|  |  |              # self.ad_human_action.check_human_info()
 | 
	
		
			
				|  |  |              self.set_ad_locations()
 | 
	
		
			
				|  |  |              self.set_ad_time()
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |              self.set_ad_title()
 | 
	
		
			
				|  |  |              self.set_ad_cpm()
 | 
	
		
			
				|  |  |              self.set_ad_human_location()
 | 
	
		
			
				|  |  |              self.set_ad_human()
 | 
	
		
			
				|  |  | +            self.set_ad_humam_gender()
 | 
	
		
			
				|  |  | +            self.set_ad_age()
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |              self.set_ad_cost()
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |              self.set_ad_idea()
 |