-
Notifications
You must be signed in to change notification settings - Fork 6
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
CARDS-59: Add support for running frontend tests using Selenium #1569
base: dev
Are you sure you want to change the base?
Conversation
public static WebDriver getDriver() | ||
{ | ||
WebDriver driver = null; | ||
WebDriverManager.chromedriver().setup(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if it would be better to use the Browsers in Docker support available in the io.github.bonigarcia.wdm.WebDriverManager
module - https://github.com/bonigarcia/webdrivermanager#browsers-in-docker. Ideally, you would want the Browser In Docker container to be part of the compose-cluster
environment and it would access the running CARDS instance at http://cardsinitial:8080
instead of http://localhost:8080
. It's just a thought for now, maybe something to do for future work.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't like that we hardcode the browser here. I would like to be able to run the tests on any browser, to catch inconsistencies.
Add selenium test module. This module can be run using `mvn clean install -Dselenium`. It runs tests using Docker to launch CARDS and Google Chrome to run the tests. To support this, `-Dselenium` will add docker to the build in addition to cleaning out any running or old CARDS docker builds. To run these tests, make sure that you have Google Chrome installed in the default install location for your operating system. The expected location can be found here: https://github.com/SeleniumHQ/selenium/wiki/ChromeDriver/01fde32d0ed245141e24151f83b7c2db31d596a4#requirements If you are using WSL, make sure that Google Chrome is installed through WSL, not just through Windows: https://scottspence.com/posts/use-chrome-in-ubuntu-wsl The current test is to login and verify that the user's avatar on the top right of the dashboard is correct. To ensure that this test ran, you can check `/selenium/target/failsafe-reports`. There should be 1 run test and no failures. If you want to check behaviour if there is a failed test, modify `LoginSelenium.java` and change `assertEquals("A"` to some other string.
Address review comments - Improve compatibility across different build environments - Improve maven configuration
Fixed compilation error
Slight log adjustment
Fixes look good: Thanks @sdumitriu |
Add framework for testing in other browsers
Added framework for testing in other browsers with known issues that will be addressed in separate PRs |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code looks pretty good although I have a few small suggestions/ideas that I have discussed in this review.
selenium/src/test/java/io/uhndata/cards/selenium/SeleniumUtils.java
Outdated
Show resolved
Hide resolved
selenium/src/test/java/io/uhndata/cards/selenium/LoginSelenium.java
Outdated
Show resolved
Hide resolved
selenium/src/test/java/io/uhndata/cards/selenium/LoginSelenium.java
Outdated
Show resolved
Hide resolved
selenium/src/test/java/io/uhndata/cards/selenium/LoginSelenium.java
Outdated
Show resolved
Hide resolved
- Move login to custom TestRule for easy re-use in different tests - Rename SeleniumUtils to improve naming scheme for future project specific selenium util files
- Fix Basic Selenium Test name
ready for re-test? |
Yes, it's ready for retest |
Add selenium test module. This module can be run using
mvn clean install -Pdocker -Dselenium
. It runs tests using Docker to launch CARDS and Google Chrome to run the tests. To support this,-Dselenium
will add docker to the build in addition to cleaning out any running or old CARDS docker builds.To run these tests, make sure that you have Google Chrome installed in the default install location for your operating system. The expected location can be found here:
https://github.com/SeleniumHQ/selenium/wiki/ChromeDriver/01fde32d0ed245141e24151f83b7c2db31d596a4#requirements
If you are using WSL, make sure that Google Chrome is installed through WSL, not just through Windows:
https://scottspence.com/posts/use-chrome-in-ubuntu-wsl
The current test is to login and verify that the user's avatar on the top right of the dashboard is correct. To ensure that this test ran, you can check
/selenium/target/failsafe-reports
. There should be 1 run test and no failures.If you want to check behaviour if there is a failed test, modify
LoginSelenium.java
and changeassertEquals("A"
to some other string.Framework has been added for supporting other browsers though there are issues with browsers other than chrome:
When no browser is provided, testing will default to Chrome
To launch with other browsers, make sure they are installed in the default install location for your operating system then run
mvn clean install -Pdocker -Dselenium -DseleniumDriver=<browser>
where
<browser>
is one ofedge
,chrome
,firefox
orsafari