コード例 #1
0
    def initialize_driver(cls, driver_type=None):

        if driver_type is not None:
            if driver_type == 'chrome':
                _chrome_driver_file_location = FileLocator.read_config_get_file_location('DriverConfiguration',
                                                                                         'ChromeDriverLocation')
                cls._driver = webdriver.Chrome(_chrome_driver_file_location)
            elif driver_type == 'ie':
                _ie_driver_file_location = FileLocator.read_config_get_file_location('DriverConfiguration',
                                                                                     'IEdriverLocation')
                cls._driver = webdriver.Ie(_ie_driver_file_location)
            elif driver_type == 'firefox':
                cls._driver = webdriver.Firefox()
            else:
                raise WebDriverException("Please provide a valid web driver! options: chrome | ie")
        else:
            cls._driver = webdriver.Firefox()
コード例 #2
0
def readconfig(section_name, key):
    _file_path = FileLocator.get_file_location('Configurations\Configuration.py')
    _conf_obj = ConfigObj(_file_path)
    _config = _conf_obj.get(section_name)[key]
    return _config
コード例 #3
0
from TestCases.PlaceOrderTest import PlaceOrderTest
from TestCases.NegativeCasesTest import NegativeCasesTest
from Utilities import HTMLTestRunner
from Utilities import FileLocator as FL

# get all test from  HomePageTest and PlaceOrderTest
home_page_tests = unittest.TestLoader().loadTestsFromTestCase(HomePageTest)
place_order_page_tests = unittest.TestLoader().loadTestsFromTestCase(PlaceOrderTest)
negative_tests = unittest.TestLoader().loadTestsFromTestCase(NegativeCasesTest)

# create a test Suite combining the tests
tests = unittest.TestSuite([home_page_tests, place_order_page_tests, negative_tests])

# Create Test Report Name
report_name = 'TestReport_' + dt.datetime.now().strftime("%Y-%m-%d_%H %M %S")

# Set the test report file location
file_location = FL.get_file_location('TestReports')

# Open the report file
outfile = open(file_location + '\\' + report_name + '.html',
               'x')
# Configure HTMLTestRunner options
runner = HTMLTestRunner.HTMLTestRunner(stream=outfile,
                                       title='Test Report',
                                       description='Test Suite Report'
                                       )

# run the suite using HTMLTEstRunner
runner.run(tests)