瀏覽代碼

MOD:落地页 等待设置

cxyu 3 年之前
父節點
當前提交
4c43492e14
共有 1 個文件被更改,包括 5 次插入10 次删除
  1. 5 10
      wechat_action/create_ad_layout.py

+ 5 - 10
wechat_action/create_ad_layout.py

@@ -24,29 +24,24 @@ class CreateAd:
     def get_into_create_page(self):
         # 进入创建页面
         self.driver.find_element_by_id('material').click()
-
         try:
             # 落地页内容有的账户有,有的无,无的默认等5s
-            print('进入')
             WebDriverWait(self.driver, 5).until(lambda driver: len(self.driver.find_elements_by_xpath(
-                '//*[@class="adui-table-tr"]')))
-            print('落地页已经有的数量',len(self.driver.find_elements_by_xpath(
-                '//*[@class="adui-table-tr"]')))
-            print('结束')
+                '//*[@class="adui-table-cell"]')))
+            for i in self.driver.find_elements_by_xpath(
+                    '//*[@class="adui-table-cell"]'):
+                WebDriverWait(self.driver, 5).until(lambda driver: i.is_displayed() and i.is_enabled())
         except Exception as e:
-            raise
             logging.error(str(e))
             time.sleep(5)
-            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())
-        # is_displayed 和 is_enabled 没有那么快就可以使用
-        time.sleep(0.1)
         create_element.click()
+        logging.info('点击新建推广页 结束')
         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(