Пример #1
0
 def get_screen(self,
                file_name=time.strftime('%Y-%m-%d_%H-%S-%M',
                                        time.localtime(time.time()))):
     '''截图'''
     self.logger.info("在此时进行截图!!")
     try:
         dit = readYaml.read("project.yaml")
         file_name = r"{}\screen\{}.png".format(dit['project']['path'],
                                                file_name)
         self.driver.get_screenshot_as_file(file_name)
         with open(file_name, 'rb') as file:
             f = file.read()
             MASTER_HELPER.attach("截图", f, type=AttachmentType.PNG)
         self.logger.info("已成功生成截图,请确认!")
     except:
         raise Exception("截图失败!")
Пример #2
0
    def get_web_driver(self):
        with pytest.allure.step("Launch site"):
            # 读取配置文件,browser
            dit = readYaml.read("testcase.yaml")
            browser = dit['browser']
            if browser == "firefox" or browser == "Firefox":
                self.driver = webdriver.Firefox()
            elif browser == "chrome" or browser == "Chrome":
                # options = webdriver.ChromeOptions()
                # options.add_extension('./uBlock_1_22_2_0.crx')
                # self.driver = webdriver.Chrome(chrome_options=options)
                self.driver = webdriver.Chrome()

            else:
                self.logger.error("Wrong browser arguement.")

            self.logger.info("new browser driver ")
            return self.driver
Пример #3
0
 def get_wap_driver(self):
     with pytest.allure.step("Launch site"):
         # 读取配置文件,browser
         dit = readYaml.read("testcase.yaml")
         browser = dit['browser']
         if browser == "firefox" or browser == "Firefox":
             # mobileEmulation = {'deviceName': 'Apple iPhone 6s'}
             # options = webdriver.FirefoxOptions()
             # options.add_argument('mobileEmulation', mobileEmulation)
             self.driver = webdriver.Firefox()
             return self.driver
         elif browser == "chrome" or browser == "Chrome":
             mobileEmulation = {'deviceName': 'Galaxy S5'}
             options = webdriver.ChromeOptions()
             options.add_experimental_option('mobileEmulation',
                                             mobileEmulation)
             self.driver = webdriver.Chrome(chrome_options=options)
             return self.driver
         self.logger.info("new wap driver ")
Пример #4
0
import pytest
from common import readYaml
import os

if __name__ == '__main__':
    '''读取重跑次数,项目路径'''
    dit = readYaml.read("testcase.yaml")
    # dit2 = readYaml.read("project.yaml")
    # print(dit, '\n', dit2)
    retrys = dit['retrys']
    modules = dit['testSuite']['module'].split(" ")
    command = [
        "-s", "-q", "--reruns",
        str(retrys), "--alluredir", "./reports/xml"
    ]
    # dirname = dit2['project']['path'].replace('\\', '/')
    # dirname=os.getcwd()
    dirname = os.path.abspath(os.path.dirname(__file__))
    print('dirname', dirname, type(dirname))
    '''拼接路径'''
    for i in modules:
        i = dirname + '/testcase/' + i
        command.insert(4, i)
    print(command)
    '''执行pytest和allure命令'''
    pytest.main(command)
    os.system("allure generate --clean reports/xml -o  reports/html")
Пример #5
0
import pytest
from common import readYaml
import os

if __name__ == '__main__':
    '''读取重跑次数,项目路径'''
    dit = readYaml.read("testcase.yaml")
    dit2 = readYaml.read("project.yaml")
    retrys = dit['retrys']
    modules = dit['testSuite']['module'].split(" ")
    command = [
        "-s", "-q", "--reruns",
        str(retrys), "--alluredir", "./reports/xml"
    ]
    dirname = dit2['project']['path']
    '''拼接路径'''
    for i in modules:
        i = dirname + '/testcase/' + i
        command.insert(4, i)
    print(command)
    '''执行pytest和allure命令'''
    pytest.main(command)
    os.system("allure generate --clean reports/xml -o  reports/html")
Пример #6
0
 def get_mobile_url(self):
     # 读取配置文件,url
     dit = readYaml.read("urls.yaml")
     mobileUrl = dit['mobileUrl']
     return mobileUrl
Пример #7
0
 def get_baidu_url(self):
     # 读取配置文件,url
     dit = readYaml.read("urls.yaml")
     baiduUrl = dit['baiduUrl']
     return baiduUrl
Пример #8
0
 def get_copa_url(self):
     # 读取配置文件,url
     dit = readYaml.read("urls.yaml")
     copaUrl = dit['copaUrl']
     return copaUrl