Skip to content

Commit bd2700b

Browse files
committed
Add Firefox and Safari to Selenium CI suite
1 parent 8bc91ee commit bd2700b

File tree

3 files changed

+18
-20
lines changed

3 files changed

+18
-20
lines changed

.github/workflows/ci.yml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -64,19 +64,19 @@ jobs:
6464
with:
6565
token: ${{ secrets.CODECOV_TOKEN }}
6666
flags: python-${{ matrix.python-version }}
67-
Selenium:
67+
selenium:
6868
needs:
69-
- standardjs
70-
runs-on: ubuntu-latest
69+
- PyTest
70+
strategy:
71+
fail-fast: false
72+
matrix:
73+
os: [ubuntu-latest, macos-latest]
74+
runs-on: ${{ matrix.os }}
7175
steps:
7276
- uses: actions/checkout@v6
73-
- name: Install Selenium
74-
run: |
75-
curl -LsSfO https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
76-
sudo dpkg -i google-chrome-stable_current_amd64.deb || sudo apt-get -f install -y
7777
- uses: astral-sh/setup-uv@v7
7878
- run: uv run pytest -m selenium
7979
- uses: codecov/codecov-action@v5
8080
with:
8181
token: ${{ secrets.CODECOV_TOKEN }}
82-
flags: selenium
82+
flags: selenium-${{ matrix.os }}

tests/conftest.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,12 @@ def random_name(n):
2525
return "-".join([x.capitalize() for x in words])
2626

2727

28-
@pytest.fixture(scope="session")
29-
def driver():
30-
chrome_options = webdriver.ChromeOptions()
31-
chrome_options.add_argument("--headless=new")
28+
@pytest.fixture(scope="session", params=["Chrome", "Safari", "Firefox"])
29+
def driver(request):
30+
options = getattr(webdriver, f"{request.param}Options")()
31+
options.add_argument("--headless")
3232
try:
33-
b = webdriver.Chrome(options=chrome_options)
33+
b = getattr(webdriver, request.param)(options=options)
3434
except WebDriverException as e:
3535
pytest.skip(str(e))
3636
else:

tests/test_forms.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -701,12 +701,11 @@ def test_widgets_selected_after_validation_error(
701701

702702
# clicking city select2 lists all available cities
703703
city_container.click()
704-
WebDriverWait(driver, 60).until(
705-
expected_conditions.presence_of_element_located(
704+
city_options = WebDriverWait(driver, 60).until(
705+
expected_conditions.visibility_of_all_elements_located(
706706
(By.CSS_SELECTOR, ".select2-results li")
707707
)
708708
)
709-
city_options = driver.find_elements(By.CSS_SELECTOR, ".select2-results li")
710709
city_names_from_browser = {option.text for option in city_options}
711710
city_names_from_db = set(City.objects.values_list("name", flat=True))
712711
assert len(city_names_from_browser) == City.objects.count()
@@ -751,12 +750,11 @@ def test_widgets_selected_after_validation_error(
751750

752751
# clicking country select2 lists reduced list to the only country available to the city
753752
country_container.click()
754-
WebDriverWait(driver, 60).until(
755-
expected_conditions.presence_of_element_located(
753+
country_options = WebDriverWait(driver, 60).until(
754+
expected_conditions.presence_of_all_elements_located(
756755
(By.CSS_SELECTOR, ".select2-results li")
757756
)
758757
)
759-
country_options = driver.find_elements(By.CSS_SELECTOR, ".select2-results li")
760758
country_names_from_browser = {option.text for option in country_options}
761759
country_names_from_db = {City.objects.get(name=city_name).country.name}
762760
assert len(country_names_from_browser) != Country.objects.count()
@@ -820,7 +818,7 @@ def test_dependent_fields_clear_after_change_parent(
820818
# check the value in city2
821819
city2_container.click()
822820
WebDriverWait(driver, 60).until(
823-
expected_conditions.presence_of_element_located(
821+
expected_conditions.visibility_of_all_elements_located(
824822
(By.CSS_SELECTOR, ".select2-results li")
825823
)
826824
)

0 commit comments

Comments
 (0)