Skip to content

Run browser tests in safari #368

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
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
5 changes: 5 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,11 @@ jobs:
python ${{ env.BUILD_PREFIX }}/bin/emrun.py --browser="firefox" --kill_exit --timeout 60 --browser-args="--headless" test_xeus_cpp.html
echo "Running test_xeus_cpp in Google Chrome"
python ${{ env.BUILD_PREFIX }}/bin/emrun.py --browser="Google Chrome" --kill_exit --timeout 60 --browser-args="--headless --no-sandbox" test_xeus_cpp.html
sudo safaridriver --enable
python -m pip install selenium
echo "Running test_xeus_cpp in Safari"
python ${{ env.BUILD_PREFIX }}/bin/emrun.py --no_browser --kill_exit --timeout 60 --browser-args="--headless --no-sandbox" test_xeus_cpp.html &
python ../../scripts/browser_tests_safari.py test_xeus_cpp.html
else
# Install Google Chrome
wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
Expand Down
14 changes: 12 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ cd test
node test_xeus_cpp.js
```

It is possible to run the Emscripten tests in a headless browser. 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
It is possible to run the Emscripten tests in a headless browser. 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 @@ -124,6 +124,16 @@ echo "Running test_xeus_cpp in Google Chrome"
python $BUILD_PREFIX/bin/emrun.py --browser="Google Chrome" --kill_exit --browser-args="--headless --no-sandbox" test_xeus_cpp.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 test_xeus_cpp in Safari"
python $BUILD_PREFIX/bin/emrun.py --no_browser --kill_exit --timeout 60 --browser-args="--headless --no-sandbox" test_xeus_cpp.html &
python ../../scripts/browser_tests_safari.py test_xeus_cpp.html
```

To do this on Ubuntu x86 execute the following

```bash
Expand Down Expand Up @@ -157,4 +167,4 @@ jupyter lite serve --XeusAddon.prefix=$PREFIX \
--contents notebooks/smallpt.ipynb \
--contents notebooks/images/marie.png \
--contents notebooks/audio/audio.wav
```
```
12 changes: 11 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ cd test
node test_xeus_cpp.js
```

It is possible to run the Emscripten tests in a headless browser. 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
It is possible to run the Emscripten tests in a headless browser. 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 @@ -136,6 +136,16 @@ echo "Running test_xeus_cpp in Google Chrome"
python python $BUILD_PREFIX/bin/emrun.py --browser="Google Chrome" --kill_exit --timeout 60 --browser-args="--headless --no-sandbox" test_xeus_cpp.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 test_xeus_cpp in Safari"
python $BUILD_PREFIX/bin/emrun.py --no_browser --kill_exit --timeout 60 --browser-args="--headless --no-sandbox" test_xeus_cpp.html &
python ../../scripts/browser_tests_safari.py test_xeus_cpp.html
```

To do this on Ubuntu x86 execute the following

```bash
Expand Down
12 changes: 11 additions & 1 deletion docs/source/InstallationAndUsage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ To test the lite build you can execute the following to run the C++ tests built
cd test
node test_xeus_cpp.js

It is possible to run the Emscripten tests in a headless browser. 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
It is possible to run the Emscripten tests in a headless browser. 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-block:: bash

Expand All @@ -105,6 +105,16 @@ It is possible to run the Emscripten tests in a headless browser. We will run ou
echo "Running test_xeus_cpp in Google Chrome"
python $BUILD_PREFIX/bin/emrun.py --browser="Google Chrome" --kill_exit --timeout 60 --browser-args="--headless --no-sandbox" test_xeus_cpp.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-block:: bash

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

To do this on Ubuntu x86 execute the following

.. code-block:: 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()