I am currently trying to work with LiveServerTestCase-based tests using the chrome driver I used https://docs.djangoproject.com/en/4.0/topics/testing/tools/#liveservertestcase as a reference and changed firefox to chrome. This is some of my code:
from selenium.webdriver.chrome.webdriver import WebDriver
from .models import Question
from time import sleep
class LoginTests(LiveServerTestCase):
@classmethod
def setUpClass(cls):
super().setUpClass()
cls.selenium = WebDriver(port = 8000)
cls.selenium.implicitly_wait(10)
@classmethod
def tearDownClass(cls):
cls.selenium.quit()
super().tearDownClass()
def test_login(self):
self.selenium.get('http://127.0.0.1:8000/')
sleep(5)
I believe I imported the required driver. The window still opens. However, this is all that shows up on the page:
{“value”:{“error”:“unknown command”,“message”:"unknown command: unknown command: ",“stacktrace”:“Backtrace:\n\tOrdinal0 [0x0122D953+2414931]\n\tOrdinal0 [0x011BF5E1+1963489]\n\tOrdinal0 [0x010AC6B8+837304]\n\tOrdinal0 [0x010F1FB1+1122225]\n\tOrdinal0 [0x010F1D99+1121689]\n\tOrdinal0 [0x0108CEC7+708295]\n\tOrdinal0 [0x0108D443+709699]\n\tOrdinal0 [0x0108D87A+710778]\n\tGetHandleVerifier [0x0149CC62+2510274]\n\tGetHandleVerifier [0x0148F760+2455744]\n\tGetHandleVerifier [0x012BEABA+551962]\n\tGetHandleVerifier [0x012BD916+547446]\n\tOrdinal0 [0x011C5F3B+1990459]\n\tOrdinal0 [0x0108CC57+707671]\n\tOrdinal0 [0x0108C708+706312]\n\tGetHandleVerifier [0x014B8E1C+2625404]\n\tBaseThreadInitThunk [0x7737FA29+25]\n\tRtlGetAppContainerNamedObjectPath [0x77DA7A7E+286]\n\tRtlGetAppContainerNamedObjectPath [0x77DA7A4E+238]\n”}}
Also, even though the test is identified as successful, I am still seeing this in the command prompt:
DevTools listening on ws://127.0.0.1:51320/devtools/browser/84e32c05-102a-4480-b3c5-86f84050cff8
[24636:22680:0602/095602.481:ERROR:device_event_log_impl.cc(214)] [09:56:02.481] USB: usb_service_win.cc:415 Could not read device interface GUIDs: The system cannot find the file specified. (0x2)
[24636:22680:0602/095602.483:ERROR:device_event_log_impl.cc(214)] [09:56:02.483] USB: usb_device_handle_win.cc:1048 Failed to read descriptor from node connection: A device attached to the system is not functioning. (0x1F)
[24636:22680:0602/095602.484:ERROR:device_event_log_impl.cc(214)] [09:56:02.484] USB: usb_device_handle_win.cc:1048 Failed to read descriptor from node connection: A device attached to the system is not functioning. (0x1F)
I am still learning my way around Django. That being said, I do not know what to make of this. Also, when I access one of my pages by running the server normally, it works just fine. However, I still want to get this working for the sake of testing. I should also add that I am trying to do this with a MySQL server. If anyone can help me figure this out, it would be much appreciated.