urls = ['https://m.beads.us', 'https://www.beads.us'] options = webdriver.ChromeOptions() options.add_argument('--headless') options.add_argument("--no-sandbox") options.add_argument('--disable-gpu') # 这里必须要外网才可以 我是本地 开了VPN, 要是本来就可以的话 就不用设置这个了 <====== options.add_argument('--proxy-server=http://127.0.0.1:1080') driver = webdriver.Chrome(options=options) RECEIVERS = '陈镇泉;林伟鸿;全建誉' LOG = log('google_页面分析检测') def send_rtx_info(msg, receivers=RECEIVERS): post_data = { "sender": "系统机器人", "receivers": receivers, "msg": msg, } requests.post("http://rtx.fbeads.cn:8012/sendInfo.php", data=post_data) def save_html(name): today_tic = time.strftime('%Y%m%d_%H%M%S', time.localtime()) save_info_dir = os.path.join(BASE_DIR, 'html', f'{name}{today_tic}.html') time.sleep(3)
import unittest from unittest.suite import _isnotsuite from helper import tools, python_config logger = tools.log('YYW_suite_test') class Suite(unittest.TestSuite): def run(self, result, debug=False): topLevel = False if getattr(result, '_testRunEntered', False) is False: result._testRunEntered = topLevel = True for index, test in enumerate(self): retry = getattr(test, "retry", python_config.RETRY) if result.shouldStop: break for i in range(1, retry + 2): if _isnotsuite(test): self._tearDownPreviousClass(test, result) self._handleModuleFixture(test, result) self._handleClassSetUp(test, result) # result._previousTestClass = test.__class__ if (getattr(test.__class__, '_classSetupFailed', False) or getattr(result, '_moduleSetUpFailed', False)): continue logger.info("用例: {}正在尝试第{}次运行!".format(test.__class__.__name__, i))
#!/usr/bin/env python # -*- coding: utf-8 -*- # @Time : 2019/11/26 9:34 # @Author : Lodge import time import random import urllib3 from selenium.webdriver.common.by import By # from selenium.webdriver.common.keys import Keys from selenium.webdriver.support import expected_conditions from selenium.webdriver.support.wait import WebDriverWait from helper import python_config, tools, exe_js LOG = tools.log('yyw_pay_order_test') urllib3.disable_warnings() # disabled requests' verify warning # 测试搜索商品相关流程 # ========================================================================================== # class PayOrder(object): def __init__(self, driver): self.driver_version = driver LOG.info(f'现在测试主页订单购买以及支付任务开始,启动的驱动为:{self.driver_version}.') self.driver = tools.chose_driver(driver, LOG, True) # self.driver.maximize_window() if not self.driver: exit(0) def get_goods_info(self):
# import re # import json import time # import random import urllib3 # import requests from threading import Thread from selenium.webdriver.common.by import By # from selenium.webdriver.common.keys import Keys from selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.support import expected_conditions from selenium.webdriver.common.action_chains import ActionChains from helper import python_config, tools, exe_js LOG = tools.log('yyw_homepage_test') urllib3.disable_warnings() # disabled requests' verify warning # 测试主页相关数据业务与登录注册功能 # ========================================================================================== # class Yyw(object): def __init__(self, driver): self.driver_version = driver LOG.info(f'现在测试主页以及登录注册状态任务开始,启动的驱动为:{self.driver_version}.') self.driver = tools.chose_driver(driver, LOG) self.driver.maximize_window() if not self.driver: exit(0) else:
#!/usr/bin/env python # -*- coding: utf-8 -*- # @Time : 2019/12/2 10:45 # @Author : Lodge import time import random import urllib3 from selenium.webdriver.common.by import By from helper import python_config, tools, range_config from selenium.webdriver.support.wait import WebDriverWait from selenium.webdriver.support import expected_conditions LOG = tools.log('yyw_personal_page') urllib3.disable_warnings() # disabled requests' verify warning # 测试分类页数据加载是否正常 # ========================================================================================== # class PersonalHomePage(object): def __init__(self, driver): self.driver_version = driver LOG.info(f'现在测试个人中心状态任务开始,启动的驱动为:{self.driver_version}.') self.driver = tools.chose_driver(driver, LOG, True) # self.driver.maximize_window() if not self.driver: exit(0) # =========================================================================== def test_profile_change_profile(self):
#!/usr/bin/env python # -*- coding: utf-8 -*- # @Time : 2019/11/22 10:19 # @Author : Lodge import time import urllib3 from helper import python_config, tools LOG = tools.log('yyw_main_page_view') urllib3.disable_warnings() # disabled requests' verify warning # 测试分类页数据加载是否正常 # ========================================================================================== # class YywHomePage(object): def __init__(self, driver): self.driver_version = driver LOG.info(f'现在测试分类页状态任务开始,启动的驱动为:{self.driver_version}.') self.driver = tools.chose_driver(driver, LOG, True) # self.driver.maximize_window() if not self.driver: exit(0) def verify_whether_in(self, n): time.sleep(5) status = True try: if n <= 5: all_goods = self.driver.find_elements_by_xpath('/html/body/div[6]/div[1]/div[2]/ul/li')
import re import json import time import random import urllib3 import requests from selenium import webdriver from multiprocessing import Pool from selenium.webdriver.common.by import By from selenium.webdriver.common.keys import Keys from selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.support import expected_conditions from helper import python_config, exe_js, tools LOG = tools.log('Ali_ADkill') urllib3.disable_warnings() # disabled requests' verify warning # ========================================================================================== # class AliAdKill(object): def __init__(self, items, killer): self.items = items self.killer = killer if self.items: self.base_url = 'https://www.aliexpress.com' self.chat_url = self.base_url + '' self.options = webdriver.ChromeOptions() self.options.add_argument("--no-sandbox")
#!/usr/bin/env python # -*- coding: utf-8 -*- # @Time : 2019/11/23 10:04 # @Author : Lodge import time import random import urllib3 from selenium.webdriver.common.by import By from selenium.webdriver.common.keys import Keys from selenium.webdriver.support import expected_conditions from selenium.webdriver.support.wait import WebDriverWait from helper import python_config, tools, range_config LOG = tools.log('yyw_search_item_test') urllib3.disable_warnings() # disabled requests' verify warning # 测试搜索商品相关流程 # ========================================================================================== # class YywSearchItem(object): def __init__(self, driver): self.driver_version = driver LOG.info(f'现在测试搜索商品信息状态任务开始,启动的驱动为:{self.driver_version}.') self.driver = tools.chose_driver(driver, LOG, True) # self.driver.maximize_window() if not self.driver: exit(0) def search_item(self):