Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ Usage

.. code-block:: python

import pytest
import pytest
import os
from selenium import webdriver
from axe_selenium_python import Axe

Expand All @@ -60,7 +61,7 @@ Usage
# Run axe accessibility checks.
results = axe.execute()
# Write results to file
axe.write_results('a11y.json', results)
axe.write_results(results, 'a11y.json')
driver.close()
# Assert no violations are found
assert len(results["violations"]) == 0, axe.report(results["violations"])
Expand Down
10 changes: 6 additions & 4 deletions axe_selenium_python/axe.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

import json
import os
from io import open
from os import path

_DEFAULT_SCRIPT = path.join(
path.dirname(__file__), "node_modules", "axe-core", "axe.min.js"
_DEFAULT_SCRIPT = os.path.join(
os.path.dirname(__file__), "node_modules", "axe-core", "axe.min.js"
)


Expand Down Expand Up @@ -100,7 +100,9 @@ def write_results(self, data, name="results.json"):
:param name: Name of file to be written to.
:param output: JSON object.
"""
with open(name, "w", encoding="utf8") as f:
filepath = os.path.join(os.getcwd(), name)

with open(filepath, "w", encoding="utf8") as f:
try:
f.write(unicode(json.dumps(data, indent=4)))
except NameError:
Expand Down