別の django コマンドでセレン テストを実行するのに問題があります。デフォルトの「test」コマンドは「tests」フォルダーを調べて、unittests を正常に実行します。問題は、フォルダー「seleniumtests」を作成し、そこにテストファイルを配置して、コマンド「test_selenium」で実行したいことです。そして、このコマンドでデフォルトのdjango「test」と同じことを別のディレクトリで実行したい。
selenium を使用した tests.py:
from django_liveserver.testcases import LiveServerTestCase
from selenium.webdriver.firefox.webdriver import WebDriver
class MySeleniumTests(LiveServerTestCase):
# fixtures = ['test-data.json']
@classmethod
def setUpClass(cls):
cls.selenium = WebDriver()
super(MySeleniumTests, cls).setUpClass()
@classmethod
def tearDownClass(cls):
super(MySeleniumTests, cls).tearDownClass()
cls.selenium.quit()
def test_admin(self):
self.selenium.get(self.live_server_url +'/admin/')
self.assertIn("Django", self.selenium.title)