Пример #1
0
 def base_operator(self,filename,pagename):
     with open(filename, 'r',encoding='gbk') as f:
         data = yaml.safe_load(f)
         logger.info(f'从文件{filename}获取数据{pagename}')
         for step in data[pagename]:
             if step['action'] == 'find_click':
                 self.find_click(step['locator'], step['value'])
             elif step['action'] == 'find_sendkeys':
                 self.find_sendkeys(step['locator'], step['value'], step['text'])
             elif step['action'] == 'find':
                 return self.find(step['locator'], step['value']).text
Пример #2
0
    def get_screen_img(self):
        """"页面截图功能"""
        file_path = (os.path.abspath("..")) + '/screenshots/'
        now = time.strftime('%Y%m%d_%H%M%S')
        screen_name = file_path + now + '.png'

        try:
            logger.info(f'正在截图{screen_name}')
            self.driver.get_screenshot_as_file(screen_name)

        except NameError as na:
            logger.error('截图失败')
            self.get_screen_img()
Пример #3
0
 def wrapper( *args, **kwargs):
     self=args[0]
     try:
         return func(*args, **kwargs)
     except:
         logger.info('正在遍历黑名单')
         black_list = ['//*[@resource-id="miui:id/buttonPanel"]',
                       '//*[@resource-id="com.xueqiu.android:id/iv_close"]']
         for one in black_list:
             ele = self.finds(By.XPATH, one)
             if len(ele) > 0:
                 ele[0].click()
         return func(*args, **kwargs)
Пример #4
0
 def test_serchmaket(self):
     price_mt = self.t.goto_main().goto_marketpage().search_price()
     logger.info(f'断言{price_mt}')
     assert float(price_mt) > 2000, '断言失败'
Пример #5
0
    def find_sendkeys(self,locator,valuee,text):
        logger.info(f'正在查找元素赋值{valuee}/{text}')

        return self.find(locator,valuee).send_keys(text)
Пример #6
0
    def find_click(self,locator,valuee):
        logger.info(f'正在查找并点击元素{valuee}')

        return self.find(locator,valuee).click()
Пример #7
0
    def finds(self,locator,valuee):
        logger.info(f'正在查找多个元素{valuee}')

        return  self.driver.find_elements(locator,valuee)