diff --git a/axe_selenium_python/axe.py b/axe_selenium_python/axe.py index c8bc6ef..0622d68 100755 --- a/axe_selenium_python/axe.py +++ b/axe_selenium_python/axe.py @@ -93,14 +93,19 @@ def report(self, violations): string += "\n\n\n" return string - def write_results(self, data, name="results.json"): + def write_results(self, data, name=None): """ Write JSON to file with the specified name. - :param name: Name of file to be written to. + :param name: Path to the file to be written to. If no path is passed + a new file will be created. :param output: JSON object. """ - filepath = os.path.join(os.getcwd(), name) + + if name: + filepath = os.path.abspath(name) + else: + filepath = os.path.join(os.path.getcwd(), name) with open(filepath, "w", encoding="utf8") as f: try: