Skip to content

Commit

Permalink
cleanup test files and update chromedriver logging
Browse files Browse the repository at this point in the history
  • Loading branch information
DonnieBLT committed Aug 12, 2023
1 parent f434cad commit dfbb55a
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 29 deletions.
31 changes: 15 additions & 16 deletions website/tests.py
Original file line number Diff line number Diff line change
@@ -1,33 +1,32 @@
from .models import Issue, IssueScreenshot
from django.core.files.uploadedfile import SimpleUploadedFile
import os

import chromedriver_autoinstaller
from django.core.files.storage import default_storage
from django.test import TestCase
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
from django.core.files.uploadedfile import SimpleUploadedFile
from django.test import LiveServerTestCase, TestCase
from django.test.utils import override_settings
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.ui import WebDriverWait
from selenium import webdriver
from django.test.utils import override_settings
import os
import chromedriver_autoinstaller

from django.test import LiveServerTestCase
from .models import Issue, IssueScreenshot

os.environ['DJANGO_LIVE_TEST_SERVER_ADDRESS'] = 'localhost:8082'
chromedriver_autoinstaller.install()

class MySeleniumTests(LiveServerTestCase):
fixtures = ['initial_data.json']

@classmethod
def setUpClass(cls):
d = DesiredCapabilities.CHROME
d["loggingPrefs"] = {"browser": "ALL"}
option = webdriver.ChromeOptions()
option.add_argument("window-size=1920,1080")

# switch these
cls.selenium = webdriver.Chrome(desired_capabilities=d, options=option)
options = webdriver.ChromeOptions()
options.add_argument("window-size=1920,1080")
options.set_capability("goog:loggingPrefs", {"browser": "ALL"})
service = Service(chromedriver_autoinstaller.install())
cls.selenium = webdriver.Chrome(service=service, options=options)

super(MySeleniumTests, cls).setUpClass()

@classmethod
Expand Down
22 changes: 9 additions & 13 deletions website/tests_urls.py
Original file line number Diff line number Diff line change
@@ -1,26 +1,22 @@
from django import test
from django.urls import reverse
from django.conf import settings
import importlib
import os

from django.contrib.staticfiles.testing import StaticLiveServerTestCase
# todo
import chromedriver_autoinstaller
from django import test
from django.conf import settings
from django.contrib.staticfiles.testing import StaticLiveServerTestCase
from django.urls import reverse
from selenium.webdriver.chrome.service import Service

# can uncomment with chromedrivermanager
os.environ["DJANGO_LIVE_TEST_SERVER_ADDRESS"] = "localhost:8082"

from selenium import webdriver
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities

d = DesiredCapabilities.CHROME
d["loggingPrefs"] = {"browser": "ALL"}

# switch these
print(chromedriver_autoinstaller.install(),"====")
driver = webdriver.Chrome(desired_capabilities=d)
service = Service(chromedriver_autoinstaller.install())

options = webdriver.ChromeOptions()
options.set_capability("goog:loggingPrefs", {"browser": "ALL"})
driver = webdriver.Chrome(service=service, options=options)


class UrlsTest(StaticLiveServerTestCase):
Expand Down

0 comments on commit dfbb55a

Please sign in to comment.