|
@@ -51,6 +51,7 @@ class CreateAd:
|
|
|
WebDriverWait(self.driver, 100).until(lambda driver: driver.find_element_by_class_name('addContent-8pexaaAGYy'))
|
|
|
self.driver.find_element_by_class_name('addContent-8pexaaAGYy').click()
|
|
|
WebDriverWait(self.driver, 100).until(lambda driver: driver.find_element_by_class_name('topArea-qOwEAeNuIn'))
|
|
|
+ logging.info('进入到推广页,编辑界面')
|
|
|
|
|
|
def set_advertisement_sign(self, layout_name):
|
|
|
# 设置广告标记
|
|
@@ -74,6 +75,8 @@ class CreateAd:
|
|
|
_.send_keys(color)
|
|
|
|
|
|
def set_head_assemb(self, info):
|
|
|
+ logging.info('开始设置头版首页')
|
|
|
+
|
|
|
def single_page_set():
|
|
|
self.driver.find_element_by_xpath('//*[@id="stage-sidebar"]/div[1]/div/div[1]/div/div').click()
|
|
|
time.sleep(random.uniform(0.1, 0.2))
|
|
@@ -274,6 +277,7 @@ class CreateAd:
|
|
|
pass
|
|
|
|
|
|
def set_page(self, config_info):
|
|
|
+ logging.info('开始设置图片模块')
|
|
|
page_link = config_info['url']
|
|
|
# 设置图片模块
|
|
|
self.driver.find_element_by_xpath('//*[@id="stage-sidebar"]/section/div[2]/div[1]/div/div').click()
|
|
@@ -289,13 +293,9 @@ class CreateAd:
|
|
|
lambda x: len([_ for _ in self.driver.find_elements_by_class_name('title-29sncpKgTl') if
|
|
|
_.is_displayed() and _.is_enabled()]) > 0)
|
|
|
|
|
|
- turn_page_buttons = self.driver.find_elements_by_class_name('paginationIcon-1EfoH0sNRF')
|
|
|
- can_use_button = []
|
|
|
- for _ in turn_page_buttons:
|
|
|
- if _.is_enabled() and _.is_displayed():
|
|
|
- can_use_button.append(_)
|
|
|
# 不断翻页获取到元素为止
|
|
|
chose_over = False
|
|
|
+ logging.info('翻页开始')
|
|
|
while True:
|
|
|
page_elements = self.driver.find_elements_by_class_name('title-29sncpKgTl')
|
|
|
for _ in page_elements:
|
|
@@ -304,6 +304,11 @@ class CreateAd:
|
|
|
_.click()
|
|
|
chose_over = True
|
|
|
break
|
|
|
+ turn_page_buttons = self.driver.find_elements_by_class_name('paginationIcon-1EfoH0sNRF')
|
|
|
+ can_use_button = []
|
|
|
+ for _ in turn_page_buttons:
|
|
|
+ if _.is_enabled() and _.is_displayed():
|
|
|
+ can_use_button.append(_)
|
|
|
if chose_over or len(can_use_button) == 0:
|
|
|
# can_use_button 数量说明是否可以翻页,如果不可以翻页,则直接停止
|
|
|
break
|
|
@@ -322,11 +327,12 @@ class CreateAd:
|
|
|
# 确保翻页成功
|
|
|
WebDriverWait(self.driver, 10).until(
|
|
|
lambda x: page_text != page_text_element.text)
|
|
|
-
|
|
|
+ logging.info('翻页结束')
|
|
|
sc_buttons = self.driver.find_elements_by_id('test_material_container_confirm')
|
|
|
for _ in sc_buttons:
|
|
|
if _.is_enabled() and _.is_displayed():
|
|
|
_.click()
|
|
|
+ logging.info('是否截图开始')
|
|
|
try:
|
|
|
WebDriverWait(self.driver, 4).until(
|
|
|
lambda driver: driver.find_element_by_class_name(
|
|
@@ -347,6 +353,7 @@ class CreateAd:
|
|
|
_.click()
|
|
|
except Exception as e:
|
|
|
logging.info(e)
|
|
|
+ logging.info('是否截图结束')
|
|
|
# 设置文本边距
|
|
|
if config_info['marginTop'] != 0 or config_info['marginBottom'] != 0:
|
|
|
distance_buttons = self.driver.find_elements_by_xpath('//input[@class="adui-input-base"]')
|
|
@@ -651,6 +658,7 @@ class CreateAd:
|
|
|
|
|
|
# 上传文件,单线程
|
|
|
# 上传文件,文件上传与整体流程切割开
|
|
|
+ logging.info('开始传送文件')
|
|
|
WebDriverWait(self.driver, 10).until(
|
|
|
lambda x: len(re.findall('token=(\d+)', self.driver.current_url)))
|
|
|
token = re.findall('token=(\d+)', self.driver.current_url)
|
|
@@ -690,6 +698,7 @@ class CreateAd:
|
|
|
|
|
|
self.driver.execute_script('window.close();')
|
|
|
self.driver.switch_to.window(self.driver.window_handles[-1])
|
|
|
+ logging.info('传送文件,结束')
|
|
|
|
|
|
def set_share_content(self, title_content, des_content):
|
|
|
self.driver.find_element_by_xpath('//*[@id="wxadcontainer"]/div[1]/div/section/header/div[2]/button[2]').click()
|
|
@@ -742,12 +751,14 @@ class CreateAd:
|
|
|
self.set_background_color(layout['pageBackColor'])
|
|
|
|
|
|
for _ in layout['content']:
|
|
|
+
|
|
|
if _['type'] == 'img':
|
|
|
self.set_page(_['content'])
|
|
|
if _['type'] == 'txt':
|
|
|
self.set_content(_['content'])
|
|
|
if _['type'] == 'followAcc':
|
|
|
self.set_follow_button(_['content'])
|
|
|
+ logging.info('设置板块,结束')
|
|
|
|
|
|
self.set_share_content(title_content=layout['shareTittle'], des_content=layout['shareDesc'])
|
|
|
|