Skip to content
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

feat: Add WebDriver module #780

Merged

Conversation

ShaharM7
Copy link
Contributor

@ShaharM7 ShaharM7 commented Feb 13, 2023

WebDriver container - use selenium docker docker-selenium.
The idea is very similar to the dynamic grid approach. When there is the demand for containers then it is raised.
The idea is:

  1. Mapping between the RemoteWebDriver and the WebDriverCotnainer by entering to RemoteWebDriver as the entry point of the WebDriverCotnainer (on the inner port of 4444)
  2. Wait for the container to be ready for running tests.
  3. Support multi browsers running
  4. Support video recording and the option to set the volume for reporting

What does the p.r describe?

The p.r describe how to raise up a webdriver container -> selenium standalone on demand of which browser to run on.
For starter the design architecture that the image will rise up for tests is a selenium standalone image that containers all the selenium grid components: selenium-grid-componenets it includes the:
router, session-queue, session map (his image call: sessions, event bus, and distributer which are the components of the hub.|
The hub joins with the node - where the tests will run.
The possible browsers are:
firefox
edge
chrome
The running can contain videos, different running options, an inspection of vnc server, and so on.

Why is it important?

When we are running e2e tests using a selenium grid, we run the tests on the prepared beforehand selenium grid, it is using a lot of computing resources because we have a full application that always running with a const number of machines that can be run on. when one developer runs his tests it is no problem, he has enough machine - nodes to run on.
But when 10 developers running e2e testing it become a more problematic and messages start be stack in the session-queue and then we get session timeout exception.
Also, we can use a dynamic grid that selenium gives us this option. But again node docker restricts us with the number of containers we are running.
If we will run on demand by white box testing approach. Each test class will run in the same container and then we will get more indications of where the tests fail.
In addition, we can get a video of the running tests by running another container in parallel to the standalone container running.
By that, we can get the attached correct video running to the test.

Related issues

Require #762

How to test this PR

To start we need to do unit testing for example: When creating a webdriver with some options then the container that will rise up contains the correct options running.

add also a basic standalone images name
@netlify
Copy link

netlify bot commented Feb 13, 2023

Deploy Preview for testcontainers-dotnet ready!

Name Link
🔨 Latest commit 7259c66
🔍 Latest deploy log https://app.netlify.com/sites/testcontainers-dotnet/deploys/640b702c246a0700083a8ffc
😎 Deploy Preview https://deploy-preview-780--testcontainers-dotnet.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

Copy link
Collaborator

@HofmeisterAn HofmeisterAn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general, the project looks good. Still, the interesting part is missing (adding and combining all the required resources to run Webdriver). Keep in mind you need to hold more resources to start the Webdriver (network and multiple container).

BTW, I replied yesterday to a similar topic on StackOverflow, maybe it's interesting for you.

src/Testcontainers.WebDriver/WebDriverBuilder.cs Outdated Show resolved Hide resolved
src/Testcontainers.WebDriver/WebDriverBuilder.cs Outdated Show resolved Hide resolved
src/Testcontainers.WebDriver/WebDriverBuilder.cs Outdated Show resolved Hide resolved
src/Testcontainers.WebDriver/WebDriverBuilder.cs Outdated Show resolved Hide resolved
src/Testcontainers.WebDriver/WebDriverBuilder.cs Outdated Show resolved Hide resolved
src/Testcontainers.WebDriver/WebDriverConfiguration.cs Outdated Show resolved Hide resolved
@vlaskal
Copy link
Contributor

vlaskal commented Feb 16, 2023

@ShaharM7 would be part of the WebDriverBuilder also automatic video recording container?
It could work like

var videoFilePath = "test/result/folder/video.mp4";
var container = new WebDriverBuilder().WithVideoRecording(videoFilePath).Build();
await container.StartAsync();

and both containers can be spun up.
In case I can help. I have already somewhere implementation of this.

@HofmeisterAn
Copy link
Collaborator

would be part of the WebDriverBuilder also automatic video recording container?

Yes, the idea is that the WebDriver module sets up everything internally. Calling StartAsync() should create all necessary resources and spin up the containers. We probably need something to store and resolve dependent resources, similar to Java's dependsOn, but for all kinds of resources.

@ShaharM7
Copy link
Contributor Author

ShaharM7 commented Feb 18, 2023

@HofmeisterAn
Great idea, we can make a generic depend on and then a custom for selenium
The order will be:

  1. create a network
  2. run selenium standalone container - browser: firefox, chrome, and edge
  3. run a selenium video container that uses the same network
  4. stop the video container and remove it
  5. stop the standalone selenium container and remove it
  6. delete the network

@ShaharM7
Copy link
Contributor Author

@vlaskal I will like your help :) contact me with .slack

Copy link
Collaborator

@HofmeisterAn HofmeisterAn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've added some suggestions. Please add an EditorConfig file to the test project directory too.

Testcontainers.sln.DotSettings Outdated Show resolved Hide resolved
src/Testcontainers.WebDriver/BrowserType.cs Outdated Show resolved Hide resolved
src/Testcontainers.WebDriver/Usings.cs Outdated Show resolved Hide resolved
src/Testcontainers.WebDriver/WebDriverBuilder.cs Outdated Show resolved Hide resolved
src/Testcontainers.WebDriver/WebDriverBuilder.cs Outdated Show resolved Hide resolved
tests/Testcontainers.WebDriver.Tests/Usings.cs Outdated Show resolved Hide resolved
src/Testcontainers.WebDriver/WebDriverBuilder.cs Outdated Show resolved Hide resolved
Testcontainers.dic Outdated Show resolved Hide resolved
src/Testcontainers.WebDriver/WebDriverBuilder.cs Outdated Show resolved Hide resolved
src/Testcontainers.WebDriver/WebDriverBuilder.cs Outdated Show resolved Hide resolved
src/Testcontainers.WebDriver/WebDriverBuilder.cs Outdated Show resolved Hide resolved
src/Testcontainers.WebDriver/WebDriverBuilder.cs Outdated Show resolved Hide resolved
src/Testcontainers.WebDriver/WebDriverBuilder.cs Outdated Show resolved Hide resolved
src/Testcontainers.WebDriver/WebDriverBuilder.cs Outdated Show resolved Hide resolved
src/Testcontainers.WebDriver/WebDriverBuilder.cs Outdated Show resolved Hide resolved
src/Testcontainers.WebDriver/WebDriverType.cs Outdated Show resolved Hide resolved
HofmeisterAn and others added 2 commits March 10, 2023 15:40
Remove expose methods that can be *easy* used by the 'WithEnvironment()' method

Co-authored-by: Andre Hofmeister <9199345+HofmeisterAn@users.noreply.github.com>
Copy link
Collaborator

@HofmeisterAn HofmeisterAn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for submitting the WebDriver module, we appreciate your contribution and the time you took to create this PR. Everything looks good to me 🙏.

@HofmeisterAn HofmeisterAn changed the title [Feature] WebDriver container feat: Add WebDriver module Mar 11, 2023
@HofmeisterAn HofmeisterAn merged commit 6850e5c into testcontainers:develop Mar 11, 2023
@ShaharM7
Copy link
Contributor Author

Thanks so much for your help :) and support too

@ShaharM7 ShaharM7 deleted the feature/WebDriverContainer branch March 11, 2023 09:31
@HofmeisterAn HofmeisterAn added the enhancement New feature or request label Apr 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants