def test_delete_dept(self): admin = AdminLandingPage(self.driver) dept = DeptPage(self.driver) _username = GetConfig('COMPANY_ADMIN') _password = GetConfig('PASSWORD') _dept_name = GetConfig('DEPT_NAME') login_to_bluesource(self, _username, _password) admin.sync() # Find specified dept and delete it delete_dept_test = TestStep("Attempt to delete a department.") admin.admin_menu_bar.navigate_department() admin.sync() dept.delete_dept(DeptTest._dept_name).scroll_element_to_center().click() sleep(1) self.driver.switch_to.alert.accept() assert not(dept.verify_dept_listed(DeptTest._dept_name)), 'Department was not successfully deleted.' delete_dept_test("Complete")
def test_add_employee(self): admin = AdminLandingPage(self.driver) employees = EmployeesPage(self.driver) _username = GetConfig('COMPANY_ADMIN') _password = GetConfig('PASSWORD') _dept_name = GetConfig('DEPT_NAME') _title_name = GetConfig('TITLE') #_new_username = GetConfig('NEW_USERNAME') # _employee_first_name = GetConfig('FIRST_NAME') # _employee_last_name = GetConfig('LAST_NAME') _employee_username = '******' % (random.randint(0, 9999)) _employee_first_name = 'First_%d' % (random.randint(0, 9999)) _employee_last_name = 'Last_%d' % (random.randint(0, 9999)) _employee_cell_phone = '(804) %d-%d' % (random.randint( 290, 999), random.randint(1000, 9999)) _name_string = '%s %s' % (_employee_first_name, _employee_last_name) _search_string = '%s, %s, %s' % ( _employee_first_name, _employee_last_name, _employee_cell_phone) login_to_bluesource(self, _username, _password) admin.sync() add_new_employee_step = TestStep('Attempt to add a new employee') admin.add_employee() admin.modal_username_field.send_keys(_employee_username) admin.modal_first_name_field.send_keys(_employee_first_name) admin.modal_last_name_field.send_keys(_employee_last_name) admin.modal_titles_drop_down.scroll_element_to_center() select_titles = Select(admin.modal_titles_drop_down) select_titles.select_by_visible_text(_title_name) admin.modal_cell_phone_field.scroll_element_to_center().send_keys( _employee_cell_phone) admin.modal_depts_drop_down.scroll_element_to_center() select_depts = Select(admin.modal_depts_drop_down) select_depts.select_by_visible_text(_dept_name) admin.create_employee() admin.sync() # cant locate search bar # admin.search_bar # admin.search_bar.send_keys(_name_string) sleep(5) admin.verify_employee(_employee_first_name, _employee_last_name, _employee_cell_phone) assert admin.action_success_msg.is_displayed( ), 'Employee was not successfully created' add_new_employee_step('Complete')
def setUpClass(cls, platform='mobile'): if not hasattr(builtins, 'threadlocal'): builtins.threadlocal = threading.local() #Use Default Driver or display device selector if HotDogBaseTest.SKIP_SELECTOR == 'True': builtins.threadlocal.config = HotDogBaseTest.DEFAULT_CONFIG else: builtins.threadlocal.config = DeviceSelector(platform=platform).getDevice()[0] # If testing mobile apps, append app info into desired caps if 'platformName' in builtins.threadlocal.config['desiredCaps']: if builtins.threadlocal.config['desiredCaps']['platformName'].upper() == 'ANDROID': builtins.threadlocal.config['desiredCaps']['app'] = GetConfig('ANDROID_APP_URL') else: builtins.threadlocal.config['desiredCaps']['app'] = GetConfig('IOS_APP_URL') # Instantiate Driver desired_caps = builtins.threadlocal.config['desiredCaps'] provider = builtins.threadlocal.config['options']['provider'] try: builtins.threadlocal.driver = cls.select_driver(cls, desired_caps, provider) except: print(sys.exc_info()[1]) raise unittest.SkipTest('Could not launch driver')
def test_delete_title(self): admin = AdminLandingPage(self.driver) titles = TitlesPage(self.driver) delete_title = TitleDetailsPage(self.driver) _username = GetConfig('COMPANY_ADMIN') _password = GetConfig('PASSWORD') login_to_bluesource(self, _username, _password) admin.sync() delete_title_step = TestStep('Attempt to delete a title.') admin.admin_menu_bar.navigate_titles() titles.sync() assert titles.verify_title_listed( TitlesTests._updated_title_name), 'Specified title not listed.' titles.delete_title(TitlesTests._updated_title_name ).scroll_element_to_center().click() self.driver.switch_to.alert.accept() titles.sync() assert titles.action_success_msg, 'Title not deleted successfully.' assert not (titles.verify_title_listed(TitlesTests._updated_title_name) ), 'Specified title is still listed' delete_title_step('Complete')
def test_add_dept(self): admin = AdminLandingPage(self.driver) dept = DeptPage(self.driver) dept_details = DeptDetailsPage(self.driver) _username = GetConfig('COMPANY_ADMIN') _password = GetConfig('PASSWORD') login_to_bluesource(self, _username, _password) admin.sync() add_new_dept_step = TestStep('Attempt to add a new department') admin.admin_menu_bar.navigate_department() dept.sync() dept.add_dept_btn.scroll_element_to_center().click() dept_details.sync() dept_details.name_textbox.send_keys(DeptTest._dept_name) dept_details.commit_dept_btn.click() dept.sync() assert dept.dept_creation_msg.is_displayed(), 'Department not created successfully' dept.verify_dept_listed(DeptTest._dept_name) add_new_dept_step('Complete')
def test_edit_title(self): admin = AdminLandingPage(self.driver) titles = TitlesPage(self.driver) edit_title = TitleDetailsPage(self.driver) _username = GetConfig('COMPANY_ADMIN') _password = GetConfig('PASSWORD') login_to_bluesource(self, _username, _password) admin.sync() edit_title_step = TestStep('Attempt to edit a title.') admin.admin_menu_bar.navigate_titles() titles.sync() assert titles.verify_title_listed( TitlesTests._title_name), 'Specified title not listed.' titles.edit_title( TitlesTests._title_name).scroll_element_to_center().click() edit_title.sync() edit_title.title_name_textbox.clear().send_keys( TitlesTests._updated_title_name) edit_title.commit_title_btn.click() titles.sync assert titles.action_success_msg, 'Title not edited successfully.' assert titles.verify_title_listed( TitlesTests._updated_title_name), 'Edited title not listed.' edit_title_step('Complete')
def test_create_title(self): admin = AdminLandingPage(self.driver) titles = TitlesPage(self.driver) new_title = TitleDetailsPage(self.driver) _username = GetConfig('COMPANY_ADMIN') _password = GetConfig('PASSWORD') login_to_bluesource(self, _username, _password) admin.sync() create_title_step = TestStep('Attempt to create a title.') admin.admin_menu_bar.navigate_titles() titles.sync() titles.new_title() new_title.sync() new_title.title_name_textbox.send_keys(TitlesTests._title_name) new_title.commit_title_btn.click() titles.sync() assert titles.action_success_msg, 'Title not created successfully' assert titles.verify_title_listed( TitlesTests._title_name), 'Title not listed' create_title_step('Complete')
def test_edit_dept(self): admin = AdminLandingPage(self.driver) dept = DeptPage(self.driver) dept_details = DeptDetailsPage(self.driver) _username = GetConfig('COMPANY_ADMIN') _password = GetConfig('PASSWORD') _dept_name = GetConfig('DEPT_NAME') updated_dept_name = "Dept_%d" % (random.randint(0, 9999)) login_to_bluesource(self, _username, _password) admin.sync() # Find specified dept and modify its name edit_dept_test = TestStep("Attempt to edit a department.") admin.admin_menu_bar.navigate_department() admin.sync() dept.edit_dept(_dept_name).scroll_element_to_center().click() dept_details.sync() dept_details.name_textbox.clear() dept_details.name_textbox.send_keys(updated_dept_name) dept_details.commit_dept_btn.click() assert dept.verify_dept_listed(updated_dept_name), 'Department not edited successfully.' edit_dept_test('Complete')
def RemoveApp(self): if 'mobile' in builtins.threadlocal.config['options']['provider']: try: builtins.threadlocal.driver.close_app() except: pass try: builtins.threadlocal.driver.remove_app(GetConfig('IOS_BUNDLE_ID')) except: pass try: builtins.threadlocal.driver.remove_app(GetConfig('ANDROID_BUNDLE_ID')) except: pass try: builtins.threadlocal.driver.quit() except: pass
def test_login_to_bluesource(self): _username = GetConfig('COMPANY_ADMIN') _password = GetConfig('PASSWORD') login_step = TestStep('Attempt login with valid admin credentials') login_to_bluesource(self, _username, _password) login_step('Complete') login_verification = TestStep( 'Verify user is logged in with admin permissions') admin = AdminLandingPage(self.driver) admin.sync() login_verification('Complete')
def desiredCaps(self, mustard=True): self.options['provider'] = 'sauceMobileWeb' self.options['manufacturer'] = self.env.find('platformName').text self.options['model'] = self.env.find('browserName').text self.options['osv'] = self.env.find('version').text self.options['mustard'] = mustard self.options['deviceName'] = self.displayString() self.options['mobileEmulation'] = True try: self.caps['parentTunnel'] = GetConfig('SAUCE_PARENT_TUNNEL') except: pass self.caps['platform'] = self.env.find('platformName').text self.caps['browserName'] = self.env.find('browserName').text self.caps['version'] = self.env.find('version').text self.caps['udid'] = "%s-%s-%s" % ( self.env.find('platformName').text.replace( '.', ''), self.env.find('browserName').text.replace( '.', ''), self.env.find('version').text.replace('.', '')) self.caps['chromeOptions'] = {} self.caps['chromeOptions']['mobileEmulation'] = {} self.caps['chromeOptions']['mobileEmulation'][ 'deviceName'] = self.env.find('mobileEmulation').text return {'desiredCaps': self.caps, 'options': self.options}
class BaseTest(HotDogBaseTest): page_url = GetConfig('APP_URL') @classmethod def setUpClass(cls): super().setUpClass(platform='desktop') def setUp(self): super().setUp() self.driver.implicitly_wait(30) def assertAlphabetical(self, list): for i in range(len(list) - 1): assert list[i].lower() < list[i + 1].lower( ), 'Items not in alphabetical order. Found entry [%s] before [%s]' % ( list[i], list[i + 1]) @Retry def assert_in_url(self, string): assert string in self.driver.current_url, 'Did not load page with string [%]' % string def assert_element_exists(self, element, name, timeout=30): start = time.time() while True: try: assert element.is_displayed( ), 'The element [%s] was not found' % name return True except: if time.time() - start > timeout: raise @classmethod def RemoveApp(self): if 'mobile' in builtins.threadlocal.config['options']['provider']: try: builtins.threadlocal.driver.close_app() except: pass try: builtins.threadlocal.driver.remove_app( GetConfig('IOS_BUNDLE_ID')) except: pass try: builtins.threadlocal.driver.remove_app( GetConfig('ANDROID_BUNDLE_ID')) except: pass try: builtins.threadlocal.driver.quit() except: pass builtins.threadlocal.driver = None @Retry def assertEqual(self, first, second, msg=None): super().assertEqual(first, second, msg)
def test_edit_employee(self): admin = AdminLandingPage(self.driver) _username = GetConfig('COMPANY_ADMIN') _password = GetConfig('PASSWORD') _dept_name = GetConfig('DEPT_NAME') _title_name = GetConfig('TITLE') _employee_username = '******' % (random.randint(0, 9999)) _employee_first_name = 'First_%d' % (random.randint(0, 9999)) _employee_last_name = 'Last_%d' % (random.randint(0, 9999)) _employee_cell_phone = '(804) %d-%d' % (random.randint( 290, 999), random.randint(1000, 9999)) _name_string = '%s %s' % (_employee_first_name, _employee_last_name) _search_string = '%s, %s, %s' % ( _employee_first_name, _employee_last_name, _employee_cell_phone) login_to_bluesource(self, _username, _password) admin.sync() assert admin.verify_employee( '6', '5', '(804) 749-2525'), 'Employee is not listed.'
import os from Helpers.FilePath import get_full_path os.environ['PROJECTFOLDER'] = get_full_path('') from builtins import range from appium_selector.DeviceSelector import DeviceSelector from hotdog.Config import GetConfig import unittest import threading import builtins import random MustardURL = GetConfig('MUSTARD_URL') + '/incomplete' MustardKey = GetConfig('MUSTARD_KEY') os.environ['AddMustard'] = 'True' builtins.threadlocal = threading.local() def chunkify(lst,n): return [ lst[i::n] for i in range(n) ] def run_all_test(tests, device): runner = unittest.TextTestRunner() builtins.threadlocal.config = device builtins.threadlocal.driver = None for test in tests: runner.run(test) def get_all_tests():
class BaseTest(HotDogBaseTest): DefaultWebDriver = BaseDriver page_url = GetConfig('APP_URL')
import os import json from hotdog.Config import GetConfig import itertools from Helpers.FilePath import get_full_path import unittest import threading import builtins import requests import random os.environ['PROJECTFOLDER'] = get_full_path('') from Helpers.LoginDatabase import get_last_login from appium_selector.DeviceSelector import DeviceSelector MustardKey = GetConfig('MUSTARD_KEY') MustardURL = GetConfig('MUSTARD_URL') + 'executions/%s/failing' % MustardKey os.environ['AddMustard'] = 'True' r = requests.get( "https://api.clmustard.orasi.com/executions/cd9f1810948838f24d79c4f2598d94bc/failing" ) builtins.threadlocal = threading.local() failed_tests = json.loads(r.content.decode("utf-8")) def run_test(device=None, test=None): login = get_last_login()
def select_driver(cls, dc, provider): runLocal = False browser_profile = None if 'grid' in provider: try: if dc['platform'].lower() == 'windows': dc['marionette'] = False if dc['browserName'] == 'internet explorer': # Will clear the cache, cookies, history, and saved form data for all running instances of Internet Explorer builtins.threadlocal.config['desiredCaps']["ie.ensureCleanSession"] = True except: pass url = cls.GRID_URL elif 'sauce' in provider: url = cls.SAUCE_URL if dc['browserName'] == 'internet explorer': dc['requireWindowFocus'] = True elif dc['browserName'] == 'chrome' and dc.get('chromeOptions') is None: builtins.threadlocal.config['desiredCaps']['chromeOptions'] = { 'excludeSwitches': ['disable-component-update']} elif provider.lower() == 'local-chrome': runLocal = True try: full = GetConfig('FULLSCREEN') except: full = False if full: co = seleniumWebdriver.ChromeOptions() co.add_argument('--start-maximized') driver = seleniumWebdriver.Chrome(chrome_options=co) else: driver = seleniumWebdriver.Chrome() elif provider.lower() == 'local-firefox:marionette': runLocal = True caps = DesiredCapabilities.FIREFOX caps['marionette'] = True driver = seleniumWebdriver.Firefox(caps) elif provider.lower() == 'local-firefox': caps = DesiredCapabilities.FIREFOX caps['marionette'] = False runLocal = True driver = seleniumWebdriver.Firefox(caps) elif provider.lower() == 'local-safari': runLocal = True driver = seleniumWebdriver.Safari() elif provider.lower() == 'local-ie': runLocal = True driver = seleniumWebdriver.Ie() elif provider.lower() == 'mcweb': url = GetConfig('MC_URL') + '/wd/hub' elif provider.lower() == 'mcmobile': url = GetConfig('MC_URL') + '/wd/hub' else: url = cls.GRID_URL # Look for the FULLSCREEN config tag, if it's there make the browser fullscreen based on the way available to set it so try: if GetConfig('FULLSCREEN'): if dc['browserName'] == 'chrome': co = seleniumWebdriver.ChromeOptions() co.add_argument('--start-maximized') dc['chromeOptions'] = co.to_capabilities()['chromeOptions'] elif dc['browserName'] == 'internet explorer': pass elif dc['browserName'] == 'firefox': pass except: pass ## TEMP WORKAROUND FOR FALING FF on Docker . This should be in appium select or device selector somewhere try: if dc['platformName'] == 'LINUX' and dc['browserName'] == 'firefox': dc['platformName'] = dc['platformName'].lower() except: pass if not runLocal: driver = webdriver.Remote( url, dc, browser_profile=browser_profile ) driver.__class__ = cls.DefaultWebDriver driver.test_steps = [] driver.tracelog = [] return driver
class HotDogBaseTest(unittest.TestCase): # HotDog Defaults. Can be overridden in child classes DefaultWebDriver = BaseWebDriver failed = False defaultTestResult = UploadResults #Boilerplate Settings Do not Change #Change in Config.xml SAUCE_USERNAME = GetConfig('SAUCE_USERNAME') SAUCE_ACCESS = GetConfig('SAUCE_ACCESS') SAUCE_URL = "http://%s:%[email protected]:80/wd/hub" % (SAUCE_USERNAME, SAUCE_ACCESS) GRID_URL = GetConfig('GRID_URL') + '/wd/hub' LOCAL_APPIUM_URL = GetConfig('LOCAL_APPIUM_URL') # set SKIP_SELECTOR to bypass the device selector & run local with platfrom from LOCAL_BROWSER try: SKIP_SELECTOR = GetConfig('SKIP_SELECTOR') LOCAL_BROWSER = GetConfig('LOCAL_BROWSER') DEFAULT_CONFIG = { 'desiredCaps': {'browserName': 'Local', 'deviceName': 'Local', 'platformName': 'Local', 'version': 'Local'}, 'options': {'manufacturer': 'local', 'mustard': False, 'provider': 'local-'+ LOCAL_BROWSER, 'osv': 'Local', 'model': 'local', "idleTimeout": 360 } } except: #xml file is missing SKIP_SELECTOR/LOCAL_BROWSER SKIP_SELECTOR = 'False' timersStart = {} timersTotal = {} testcase_id = '' try: app_env = os.environ['APP_DATA'].split('<|>') app_env = app_env[0] print('APP_DATA Environment Data found. Appending app_env [%s] to test' % app_env[0]) app_url = app_env[1] print('APP_DATA Environment Data found. Appending app_url [%s] to test' % app_env[1]) except: pass @classmethod def setUpClass(cls, platform='mobile'): if not hasattr(builtins, 'threadlocal'): builtins.threadlocal = threading.local() #Use Default Driver or display device selector if HotDogBaseTest.SKIP_SELECTOR == 'True': builtins.threadlocal.config = HotDogBaseTest.DEFAULT_CONFIG else: builtins.threadlocal.config = DeviceSelector(platform=platform).getDevice()[0] # If testing mobile apps, append app info into desired caps if 'platformName' in builtins.threadlocal.config['desiredCaps']: if builtins.threadlocal.config['desiredCaps']['platformName'].upper() == 'ANDROID': builtins.threadlocal.config['desiredCaps']['app'] = GetConfig('ANDROID_APP_URL') else: builtins.threadlocal.config['desiredCaps']['app'] = GetConfig('IOS_APP_URL') # Instantiate Driver desired_caps = builtins.threadlocal.config['desiredCaps'] provider = builtins.threadlocal.config['options']['provider'] try: builtins.threadlocal.driver = cls.select_driver(cls, desired_caps, provider) except: print(sys.exc_info()[1]) raise unittest.SkipTest('Could not launch driver') def setUp(self): # Setup Test self.desired_caps = builtins.threadlocal.config['desiredCaps'] self.options = builtins.threadlocal.config['options'] self.options['deviceName'] = self.environmentName() self.provider = self.options['provider'] self.resultLink = None # Reinitialize driver if destroyed if not builtins.threadlocal.driver: try: self.driver = self.__class__.select_driver(self, self.desired_caps, self.provider) builtins.threadlocal.driver = self.driver self.continueWithDriver = False except: print("Testcase [%s] COULD NOT START on device [%s]" % (self._testMethodName, self.options['deviceName'])) print(sys.exc_info()[1]) raise unittest.SkipTest('Could not launch driver') else: self.driver = builtins.threadlocal.driver self.continueWithDriver = True # Create root node for Step Log builtins.threadlocal.driver.step_log = StepLog() self.end_step = self.add_test_step(self._testMethodName) print("Testcase [%s] started on device [%s]" % (self._testMethodName, self.options['deviceName'])) def environmentName(self): if 'deviceName' in self.options: return self.options['deviceName'] elif 'udid' in self.desired_caps: return self.desired_caps['udid'] else: return self.options['provider'] def tearDown(self): if 'sauce' in self.provider.lower(): sauce = SauceClient(self.SAUCE_USERNAME, self.SAUCE_ACCESS) self.resultLink = "https://saucelabs.com/beta/tests/%s" % self.driver.session_id try: if sys.exc_info() == (None, None, None): sauce.jobs.update_job(self.driver.session_id, passed=True, name=self._testMethodName) else: sauce.jobs.update_job(self.driver.session_id, passed=False, name=self._testMethodName) except: pass @classmethod def tearDownClass(cls): cls.RemoveApp() @classmethod def RemoveApp(self): if 'mobile' in builtins.threadlocal.config['options']['provider']: try: builtins.threadlocal.driver.close_app() except: pass try: builtins.threadlocal.driver.remove_app(GetConfig('IOS_BUNDLE_ID')) except: pass try: builtins.threadlocal.driver.remove_app(GetConfig('ANDROID_BUNDLE_ID')) except: pass try: builtins.threadlocal.driver.quit() except: pass def add_test_step(self, step_name): self.driver.step_log.add_step(Step(step_name)) return self.driver.step_log.close_step def run(self, result=None): try: super().run( result= self.defaultTestResult()) except: try: self.driver.quit() except: pass raise def timerStart(self, name): self.timersStart[name] = time() def timerStop(self, name): self.timersTotal[name] = time() - self.timersStart[name] if self.options['mustard']: Mustard.UploadPerformance(Mustard.getDeviceID(self), name, self.timersTotal[name]) @staticmethod def select_driver(cls, dc, provider): runLocal = False browser_profile = None if 'grid' in provider: try: if dc['platform'].lower() == 'windows': dc['marionette'] = False if dc['browserName'] == 'internet explorer': # Will clear the cache, cookies, history, and saved form data for all running instances of Internet Explorer builtins.threadlocal.config['desiredCaps']["ie.ensureCleanSession"] = True except: pass url = cls.GRID_URL elif 'sauce' in provider: url = cls.SAUCE_URL if dc['browserName'] == 'internet explorer': dc['requireWindowFocus'] = True elif dc['browserName'] == 'chrome' and dc.get('chromeOptions') is None: builtins.threadlocal.config['desiredCaps']['chromeOptions'] = { 'excludeSwitches': ['disable-component-update']} elif provider.lower() == 'local-chrome': runLocal = True try: full = GetConfig('FULLSCREEN') except: full = False if full: co = seleniumWebdriver.ChromeOptions() co.add_argument('--start-maximized') driver = seleniumWebdriver.Chrome(chrome_options=co) else: driver = seleniumWebdriver.Chrome() elif provider.lower() == 'local-firefox:marionette': runLocal = True caps = DesiredCapabilities.FIREFOX caps['marionette'] = True driver = seleniumWebdriver.Firefox(caps) elif provider.lower() == 'local-firefox': caps = DesiredCapabilities.FIREFOX caps['marionette'] = False runLocal = True driver = seleniumWebdriver.Firefox(caps) elif provider.lower() == 'local-safari': runLocal = True driver = seleniumWebdriver.Safari() elif provider.lower() == 'local-ie': runLocal = True driver = seleniumWebdriver.Ie() elif provider.lower() == 'mcweb': url = GetConfig('MC_URL') + '/wd/hub' elif provider.lower() == 'mcmobile': url = GetConfig('MC_URL') + '/wd/hub' else: url = cls.GRID_URL # Look for the FULLSCREEN config tag, if it's there make the browser fullscreen based on the way available to set it so try: if GetConfig('FULLSCREEN'): if dc['browserName'] == 'chrome': co = seleniumWebdriver.ChromeOptions() co.add_argument('--start-maximized') dc['chromeOptions'] = co.to_capabilities()['chromeOptions'] elif dc['browserName'] == 'internet explorer': pass elif dc['browserName'] == 'firefox': pass except: pass ## TEMP WORKAROUND FOR FALING FF on Docker . This should be in appium select or device selector somewhere try: if dc['platformName'] == 'LINUX' and dc['browserName'] == 'firefox': dc['platformName'] = dc['platformName'].lower() except: pass if not runLocal: driver = webdriver.Remote( url, dc, browser_profile=browser_profile ) driver.__class__ = cls.DefaultWebDriver driver.test_steps = [] driver.tracelog = [] return driver
import os import json from hotdog.Config import GetConfig import itertools from Helpers.FilePath import get_full_path import unittest import threading import builtins import requests import random os.environ['PROJECTFOLDER'] = get_full_path('') from appium_selector.DeviceSelector import DeviceSelector MustardURL = GetConfig('MUSTARD_URL') + '/failures' MustardKey = GetConfig('MUSTARD_KEY') os.environ['AddMustard'] = 'True' r = requests.post(MustardURL, data={ 'project_id': MustardKey, }) builtins.threadlocal = threading.local() failed_tests = json.loads(r.content.decode("utf-8")) def run_test(device=None): tests_to_run = [] for t in failed_tests:
import requests from hotdog.Config import GetConfig from Helpers.FilePath import get_full_path import unittest import threading import builtins import os os.environ['PROJECTFOLDER'] = get_full_path('') from appium_selector.DeviceSelector import DeviceSelector MustardURL = GetConfig('MUSTARD_URL').replace('results', 'executions') + '/close' MustardKey = GetConfig('MUSTARD_KEY') # r = requests.post(MustardURL, data={'project_key': MustardKey,}) os.environ['AddMustard'] = 'True' builtins.threadlocal = threading.local() def run_all_test(device=None): builtins.threadlocal.config = device builtins.threadlocal.driver = None builtins.threadlocal.keepSession = False loader = unittest.TestLoader() tests = loader.discover('./Tests/', pattern='*Tests.py') runner = unittest.TextTestRunner()
import datetime import requests import os import base64 import sys from hotdog.FilePath import get_full_path from hotdog.Config import GetConfig import time MustardURL = GetConfig('MUSTARD_URL') MustardKey = GetConfig('MUSTARD_KEY') PROJECTFOLDER = GetConfig('ProjectFolder') def takeScreenshot(driver, imageName): worked = True try: driver.save_screenshot(imageName) except: try: driver.get_screenshot_as_file(imageName) except: worked = False return worked def UploadToMustard(test, status, error_message=None, stacktrace=None): if test.options['mustard']: