def setUp(self): super(nsUIBaseTestCase, self).setUp() if self.base_url is not None: actions.set_base_url(self.base_url) actions._set_wait_timeout(self.wait_timeout, self.wait_poll) # Ensures nsUI.actions will find me actions._test = self if self.xserver_headless and self.xvfb is None: # If we need to run headless and no xvfb is already running, start # a new one for the current test, scheduling the shutdown for the # end of the test. self.xvfb = use_xvfb_server(self) config.results_directory = self.results_directory _make_results_dir() # Fix: Test Mile : Selenium gives errors in an unpredictable way as it is not able # to delete the previously created temp file for the firefox webdriver extension # Explicitly deleting temp folders before launching the browser import tempfile temp_dir = tempfile.gettempdir() import os, shutil for d in os.listdir(temp_dir): try: full_path = os.path.join(temp_dir, d) if os.path.isdir(full_path): if d.endswith(".xpi") or d.startswith("tmp"): shutil.rmtree(full_path) elif d.endswith(".part"): os.remove(full_path) except: # can't do muich about the browser acquiring a lock on certain temp dirs pass # Launching the browser self.start_browser() self.addCleanup(self.stop_browser) if self.screenshots_on: self.addOnException(self.take_screenshot_and_page_dump) if self.debug_post_mortem: self.addOnException( self.print_exception_and_enter_post_mortem) if self.extended_report: self.addOnException(self.report_extensively)
def setUp(self): if allscrewedup : print "ENTERING SETUP" self.script_path = os.path.join(self.script_dir, self.script_name) sys.path.append(self.script_dir) self.addCleanup(sys.path.remove, self.script_dir) self._compile_script() # The script may override some settings. The default value for # JAVASCRIPT_DISABLED and ASSUME_TRUSTED_CERT_ISSUER are False, so if # the user mentions them in his script, it's to turn them on. Also, # getting our hands on the values used in the script is too hackish ;) if 'JAVASCRIPT_DISABLED' in self.code.co_names: self.javascript_disabled = True if 'ASSUME_TRUSTED_CERT_ISSUER' in self.code.co_names: self.assume_trusted_cert_issuer = True nsUITestCase.setUp(self) # Start with default values actions.reset_base_url() actions._set_wait_timeout(10, 0.1) # Possibly inject parametrization from associated .csv file context.populate_context(self.context, self.script_path, self.browser_type, self.javascript_disabled)