Skip to content

Instantly share code, notes, and snippets.

@Xilesun
Last active February 3, 2018 07:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Xilesun/fa3136ca1b7acb95eec5a55208c4bce0 to your computer and use it in GitHub Desktop.
Save Xilesun/fa3136ca1b7acb95eec5a55208c4bce0 to your computer and use it in GitHub Desktop.
python代码段
import os
# Import all files in modules dynamically
for module in os.listdir(os.path.dirname(__file__)):
if module == '__init__.py' or module[-3:] != '.py':
continue
__import__(module[:-3], locals(), globals())
del module
# Store testCase() in all files into modules array
modules = []
for loader, name, is_pkg in pkgutil.walk_packages(testCase.__path__):
modules.append(loader.find_module(name).load_module(name))
# Run every testCase():
for module in modules:
module.testCase(self.key)
# Take a screenshot of the results
# Get current file name
base = os.path.basename(__file__)
basename = os.path.splitext(base)[0]
path = os.path.join(group, basename)
if not os.path.isdir(path):
os.mkdir(path)
# Get timestamp
timestr = time.strftime("%Y%m%d%H%M%S")
filename = '%s.png' % timestr
pic = os.path.join(path, filename)
driver.save_screenshot(pic)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment