Selenium test failed with RuntimeError: Database access not allowed, use the "django_db" mark, or the "db" or "transactional_db" fixtures to enable it
I'm running tests with selenium and i want to test the admin panel in django
so i made the below tests
import pytest
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.by import By
#create pytest database with admin credintials
@pytest.mark.selenium
def test_create_admin_user(create_admin_user):
assert create_admin_user.__str__() == "admin"
@pytest.mark.django_db
def test_dashboard_admin_login(live_server, create_admin_user, firefox_browser_instance):
browser = firefox_browser_instance
browser.get(("%s%s" % (live_server.url, "/admin/login")))
username = browser.find_element(By.NAME, 'username')
password = browser.find_element(By.NAME, 'password')
submit = browser.find_element(By.XPATH, '//input[@value = "Log in"]')
username.send_keys("admin")
password.send_keys("admin")
submit.send_keys(Keys.RETURN)
assert "Site administration" in browser.page_source
fixtures:
import pytest
@pytest.fixture
def create_admin_user(django_user_model):
"""
Return admin user
"""
return django_user_model.objects.create_superuser("admin", "admin@admin.com", "admin")
confest:
pytest_plugins = [
"core.test_setup.fixtures",
"core.test_setup.selenium",
]
when i run the tests it appears that 1 passed, 1 failed
the one passed is test_create_admin_user
and the one failed is def test_dashboard_admin_login
Error:
RuntimeError: Database access not allowed, use the "django_db" mark, or the "db" or "transactional_db" fixtures to enable it.