Skip to content

Run browser tests in safari #684

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jul 31, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .github/workflows/deploy-pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,14 @@ jobs:
emrun --browser="Google Chrome" --kill_exit --timeout 60 --browser-args="--headless --no-sandbox" CppInterOpTests.html
echo "Running DynamicLibraryManagerTests in Google Chrome"
emrun --browser="Google Chrome" --kill_exit --timeout 60 --browser-args="--headless --no-sandbox" DynamicLibraryManagerTests.html
sudo safaridriver --enable
python -m pip install selenium
echo "Running CppInterOpTests in Safari"
emrun --no_browser --kill_exit --timeout 60 --browser-args="--headless --no-sandbox" CppInterOpTests.html &
python ../../../scripts/browser_tests_safari.py CppInterOpTests.html
echo "Running DynamicLibraryManagerTests in Safari"
emrun --no_browser --kill_exit --timeout 60 --browser-args="--headless --no-sandbox" DynamicLibraryManagerTests.html &
python ../../../scripts/browser_tests_safari.py DynamicLibraryManagerTests.html

cd ../../
emmake make -j ${{ env.ncpus }} install
Expand Down
14 changes: 14 additions & 0 deletions .github/workflows/emscripten.yml
Original file line number Diff line number Diff line change
Expand Up @@ -571,6 +571,14 @@ jobs:
emrun --browser="Google Chrome" --kill_exit --timeout 60 --browser-args="--headless --no-sandbox" CppInterOpTests.html
echo "Running DynamicLibraryManagerTests in Google Chrome"
emrun --browser="Google Chrome" --kill_exit --timeout 60 --browser-args="--headless --no-sandbox" DynamicLibraryManagerTests.html
sudo safaridriver --enable
python -m pip install selenium
echo "Running CppInterOpTests in Safari"
emrun --no_browser --kill_exit --timeout 60 --browser-args="--headless --no-sandbox" CppInterOpTests.html &
python ../../../scripts/browser_tests_safari.py CppInterOpTests.html
echo "Running DynamicLibraryManagerTests in Safari"
emrun --no_browser --kill_exit --timeout 60 --browser-args="--headless --no-sandbox" DynamicLibraryManagerTests.html &
python ../../../scripts/browser_tests_safari.py DynamicLibraryManagerTests.html
else
export ARCHITECHURE=$(uname -m)
if [[ "$ARCHITECHURE" != "aarch64" ]]; then
Expand Down Expand Up @@ -706,6 +714,12 @@ jobs:
emrun --browser="Google Chrome" --kill_exit --timeout 60 --browser-args="--headless --no-sandbox" CppInterOpTests.html
echo "Running DynamicLibraryManagerTests in Google Chrome"
emrun --browser="Google Chrome" --kill_exit --timeout 60 --browser-args="--headless --no-sandbox" DynamicLibraryManagerTests.html
echo "Running CppInterOpTests in Safari"
emrun --no_browser --kill_exit --timeout 60 --browser-args="--headless --no-sandbox" CppInterOpTests.html &
python ../../../scripts/browser_tests_safari.py CppInterOpTests.html
echo "Running DynamicLibraryManagerTests in Safari"
emrun --no_browser --kill_exit --timeout 60 --browser-args="--headless --no-sandbox" DynamicLibraryManagerTests.html &
python ../../../scripts/browser_tests_safari.py DynamicLibraryManagerTests.html
else
export ARCHITECHURE=$(uname -m)
if [[ "$ARCHITECHURE" != "aarch64" ]]; then
Expand Down
15 changes: 14 additions & 1 deletion Emscripten-build-instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ It is possible to run the Emscripten tests in a headless browser. To do this we
cd ./unittests/CppInterOp/
```

We will run our tests in a fresh installed browser. Installing the browsers, and running the tests within the installed browsers will be platform dependent. To do this on MacOS execute the following
We will run our tests in a fresh installed browser. Installing the browsers, and running the tests within the installed browsers will be platform dependent. To do this for Chrome and Firefox on MacOS execute the following

```bash
wget "https://download.mozilla.org/?product=firefox-latest&os=osx&lang=en-US" -O Firefox-latest.dmg
Expand All @@ -249,6 +249,19 @@ echo "Running DynamicLibraryManagerTests in Google Chrome"
emrun --browser="Google Chrome" --kill_exit --timeout 60 --browser-args="--headless --no-sandbox" DynamicLibraryManagerTests.html
```

To run tests in Safari you can make use of safaridriver. How to enable this will depend on
your MacOS operating system, and is best to consult [safaridriver](https://developer.apple.com/documentation/webkit/testing-with-webdriver-in-safari). You will also need to install the Selenium
python package. This only needs to be enable once, and then you can execute the following to run the tests in Safari

```bash
echo "Running CppInterOpTests in Safari"
emrun --no_browser --kill_exit --timeout 60 --browser-args="--headless --no-sandbox" CppInterOpTests.html &
python ../../../scripts/browser_tests_safari.py CppInterOpTests.html
echo "Running DynamicLibraryManagerTests in Safari"
emrun --no_browser --kill_exit --timeout 60 --browser-args="--headless --no-sandbox" DynamicLibraryManagerTests.html &
python ../../../scripts/browser_tests_safari.py DynamicLibraryManagerTests.html
```

To do this on Ubuntu x86 execute the following

```bash
Expand Down
15 changes: 14 additions & 1 deletion docs/Emscripten-build-instructions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ It is possible to run the Emscripten tests in a headless browser. To do this we

cd ./unittests/CppInterOp/

We will run our tests in a fresh installed browser. Installing the browsers, and running the tests within the installed browsers will be platform dependent. To do this on MacOS execute the following
We will run our tests in a fresh installed browser. Installing the browsers, and running the tests within the installed browsers will be platform dependent. To do this for Chrome and Firefox on MacOS execute the following

.. code:: bash

Expand All @@ -272,6 +272,19 @@ We will run our tests in a fresh installed browser. Installing the browsers, and
echo "Running DynamicLibraryManagerTests in Google Chrome"
emrun --browser="Google Chrome" --kill_exit --timeout 60 --browser-args="--headless --no-sandbox" DynamicLibraryManagerTests.html

To run tests in Safari you can make use of safaridriver. How to enable this will depend on
your MacOS operating system, and is best to consult `safaridriver <https://developer.apple.com/documentation/webkit/testing-with-webdriver-in-safari>`_. You will also need to install the Selenium
python package. This only needs to be enable once, and then you can execute the following to run the tests in Safari

.. code:: bash

echo "Running CppInterOpTests in Safari"
emrun --no_browser --kill_exit --timeout 60 --browser-args="--headless --no-sandbox" CppInterOpTests.html &
python ../../../scripts/browser_tests_safari.py CppInterOpTests.html
echo "Running DynamicLibraryManagerTests in Safari"
emrun --no_browser --kill_exit --timeout 60 --browser-args="--headless --no-sandbox" DynamicLibraryManagerTests.html &
python ../../../scripts/browser_tests_safari.py DynamicLibraryManagerTests.html

To do this on Ubuntu x86 execute the following

.. code:: bash
Expand Down
9 changes: 9 additions & 0 deletions scripts/browser_tests_safari.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import sys
import time
from selenium import webdriver

driver = webdriver.Safari()
driver.get("http://localhost:6931/" + sys.argv[1])

time.sleep(60)
driver.quit()
Loading