|
@@ -25,13 +25,21 @@ class CreateAd:
|
|
|
|
|
|
self.driver.find_element_by_id('material').click()
|
|
|
|
|
|
- WebDriverWait(self.driver, 10).until(lambda driver: driver.find_element_by_class_name('ui-fl-r'))
|
|
|
- create_element = self.driver.find_element_by_class_name('ui-fl-r')
|
|
|
+ try:
|
|
|
+
|
|
|
+ WebDriverWait(self.driver, 5).until(lambda driver: self.driver.find_elements_by_xpath(
|
|
|
+ '//*[@class="adui-table-tr"]'))
|
|
|
+ except:
|
|
|
+ pass
|
|
|
+ WebDriverWait(self.driver, 10).until(lambda driver: self.driver.find_element_by_xpath(
|
|
|
+ '//*[@class="ui-fl-r adui-button-base adui-button-primary adui-button-small"]'))
|
|
|
+ create_element = self.driver.find_element_by_xpath(
|
|
|
+ '//*[@class="ui-fl-r adui-button-base adui-button-primary adui-button-small"]')
|
|
|
WebDriverWait(self.driver, 10).until(
|
|
|
lambda driver: create_element.is_displayed() and create_element.is_enabled())
|
|
|
|
|
|
time.sleep(0.1)
|
|
|
- self.driver.find_element_by_class_name('ui-fl-r').click()
|
|
|
+ create_element.click()
|
|
|
WebDriverWait(self.driver, 5).until(lambda driver: driver.find_element_by_css_selector(
|
|
|
'#wxadcontainer > div:nth-child(1) > div:nth-child(2) > div.dialog-1fj_N480ZT > div > div > div:nth-child(1) > div.dialogCardFooter-17KpBD1lgN > button'))
|
|
|
self.driver.find_element_by_css_selector(
|
|
@@ -64,10 +72,24 @@ class CreateAd:
|
|
|
|
|
|
def set_head_assemb(self, 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))
|
|
|
|
|
|
+
|
|
|
+ if info['content']['adSite'] != '朋友圈信息流':
|
|
|
+ self.driver.find_elements_by_xpath('//*[@class="adui-radio-indicator"]')[1].click()
|
|
|
+ elif info['content']['outerStyle'] != '常规广告':
|
|
|
+ select_e = self.driver.find_elements_by_xpath('//*[@class="adui-select-selection-item"]')
|
|
|
+ for _ in select_e:
|
|
|
+ if _.text == '常规广告':
|
|
|
+ _.click()
|
|
|
+ time.sleep(0.1)
|
|
|
+ select_e = self.driver.find_elements_by_xpath('//*[@class="adui-select-item-option-content"]')
|
|
|
+ for _ in select_e:
|
|
|
+ if _.text == '卡片广告':
|
|
|
+ _.click()
|
|
|
+
|
|
|
+
|
|
|
file_name = re.split('\/', info['content']['url'])[-1]
|
|
|
self.driver.find_element_by_class_name('upload-img-item-inner-2gsg7NjaZ8').click()
|
|
|
WebDriverWait(self.driver, 10).until(
|
|
@@ -248,7 +270,8 @@ class CreateAd:
|
|
|
|
|
|
pass
|
|
|
|
|
|
- def set_page(self, page_link):
|
|
|
+ def set_page(self, config_info):
|
|
|
+ page_link = config_info['url']
|
|
|
|
|
|
self.driver.find_element_by_xpath('//*[@id="stage-sidebar"]/section/div[2]/div[1]/div/div').click()
|
|
|
time.sleep(random.uniform(0.1, 0.2))
|
|
@@ -321,6 +344,21 @@ class CreateAd:
|
|
|
_.click()
|
|
|
except Exception as e:
|
|
|
logging.info(e)
|
|
|
+
|
|
|
+ if config_info['marginTop'] != 0 or config_info['marginBottom'] != 0:
|
|
|
+ distance_buttons = self.driver.find_elements_by_xpath('//input[@class="adui-input-base"]')
|
|
|
+ distance_buttons_can_use = []
|
|
|
+ for _ in distance_buttons:
|
|
|
+ if _.is_enabled() and _.is_displayed() and _.get_attribute("value") == '0':
|
|
|
+ distance_buttons_can_use.append(_)
|
|
|
+ distance_buttons_can_use[0].click()
|
|
|
+ for i in range(4):
|
|
|
+ distance_buttons_can_use[0].send_keys(Keys.BACKSPACE)
|
|
|
+ distance_buttons_can_use[0].send_keys(config_info['marginTop'])
|
|
|
+ distance_buttons_can_use[1].click()
|
|
|
+ for i in range(4):
|
|
|
+ distance_buttons_can_use[1].send_keys(Keys.BACKSPACE)
|
|
|
+ distance_buttons_can_use[1].send_keys(config_info['marginBottom'])
|
|
|
logging.info('图片模块设置结束')
|
|
|
|
|
|
def set_content(self, config_info):
|
|
@@ -338,7 +376,7 @@ class CreateAd:
|
|
|
_.send_keys(config_info['text'])
|
|
|
|
|
|
|
|
|
- if config_info['color'] != '595959':
|
|
|
+ if config_info['color'] != '#595959':
|
|
|
color_buttons = self.driver.find_elements_by_class_name('adui-cp-picker')
|
|
|
c_buttons_can_use = []
|
|
|
for _ in color_buttons:
|
|
@@ -355,7 +393,6 @@ class CreateAd:
|
|
|
|
|
|
|
|
|
if config_info['fontWeight'] != 'normal':
|
|
|
-
|
|
|
big_elements = self.driver.find_elements_by_class_name('adui-button-content')
|
|
|
for _ in big_elements:
|
|
|
if _.text == '加粗' and _.is_displayed() and _.is_enabled():
|
|
@@ -363,7 +400,6 @@ class CreateAd:
|
|
|
|
|
|
|
|
|
if config_info['textAlign'] != 'left':
|
|
|
-
|
|
|
loc_buttons = self.driver.find_elements_by_xpath(
|
|
|
"//div[contains(@class, 'adui-button-group_banner')]//button")
|
|
|
loc_buttons_can_use = []
|
|
@@ -390,8 +426,12 @@ class CreateAd:
|
|
|
for _ in str_num_buttons:
|
|
|
if _.is_displayed() and _.is_enabled():
|
|
|
str_num_can_use.append(_)
|
|
|
- str_num_map = {14: 0, 16: 1, 18: 2, 20: 3, 24: 4, 36: 5}
|
|
|
- str_num_can_use[str_num_map[config_info['fontSize']]].click()
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ for _ in str_num_can_use:
|
|
|
+ if _.text == str(config_info['fontSize']):
|
|
|
+ _.click()
|
|
|
|
|
|
|
|
|
if config_info['marginTop'] != 22 or config_info['marginBottom'] != 22:
|
|
@@ -413,9 +453,20 @@ class CreateAd:
|
|
|
|
|
|
|
|
|
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
self.driver.find_element_by_xpath('//*[@id="stage-sidebar"]/section/div[4]/div[2]/div/div').click()
|
|
|
+
|
|
|
+
|
|
|
+ if 'follow' in config_info.keys():
|
|
|
+ if not config_info['follow']:
|
|
|
+ time.sleep(0.1)
|
|
|
+ follow_bs = self.driver.find_elements_by_xpath(
|
|
|
+ '//*[@class="form-caption-3Xp3o6Drwf"]/div/span')
|
|
|
+
|
|
|
+ for _ in follow_bs:
|
|
|
+ if _.is_displayed() and _.is_enabled():
|
|
|
+ _.click()
|
|
|
+
|
|
|
|
|
|
input_elements = self.driver.find_elements_by_xpath('//input[@class="adui-input-base"]')
|
|
|
for _ in input_elements:
|
|
@@ -665,7 +716,7 @@ class CreateAd:
|
|
|
|
|
|
for _ in layout['content']:
|
|
|
if _['type'] == 'img':
|
|
|
- self.set_page(page_link=_['content']['url'])
|
|
|
+ self.set_page(_['content'])
|
|
|
if _['type'] == 'txt':
|
|
|
self.set_content(_['content'])
|
|
|
if _['type'] == 'followAcc':
|