This repository was archived by the owner on Jul 21, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGridSetup.cs
More file actions
69 lines (57 loc) · 1.93 KB
/
GridSetup.cs
File metadata and controls
69 lines (57 loc) · 1.93 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
using DotNet.Testcontainers.Builders;
namespace WeatherForcast.Selenium.Tests;
[SetUpFixture]
public class GridSetup
{
public static String WebDriverUrl;
[OneTimeSetUp]
public async Task Setup()
{
var gridNetwork = new NetworkBuilder()
.WithName("seleniumgridnetwork")
.Build();
var hubEnvironment = new Dictionary<string, string>()
{
{ "VNC_NO_PASSWORD", "1" },
{ "SE_NODE_MAX_INSTANCES", "4" },
{ "SE_NODE_MAX_SESSIONS", "4" }
};
var nodeEnvironment = new Dictionary<string, string>()
{
{ "SE_EVENT_BUS_HOST", "selenium-hub" },
{ "SE_EVENT_BUS_PUBLISH_PORT", "4442" },
{ "SE_EVENT_BUS_SUBSCRIBE_PORT", "4443" },
{ "SE_NODE_MAX_SESSIONS", "4" },
{ "SE_NODE_MAX_INSTANCES", "4" },
{ "SE_NODE_SESSION_TIMEOUT", "180" }
};
var hubContainer = new ContainerBuilder()
.WithImage("selenium/hub:4.18.1")
.WithName("selenium-hub")
.WithNetwork(gridNetwork)
.WithEnvironment(hubEnvironment)
.WithPortBinding("4442", "4442")
.WithPortBinding("4443", "4443")
.WithPortBinding("4444", "4444")
.WithWaitStrategy(Wait.ForUnixContainer().UntilPortIsAvailable(4444))
.Build();
var fireFoxContainer = new ContainerBuilder()
.WithImage("selenium/node-firefox:123.0")
.WithName("ffNode")
.WithNetwork(gridNetwork)
.WithEnvironment(nodeEnvironment)
.Build();
var chromeContainer = new ContainerBuilder()
.WithImage("selenium/node-chrome:123.0")
.WithName("chromeNode")
.WithNetwork(gridNetwork)
.WithEnvironment(nodeEnvironment)
.Build();
await hubContainer.StartAsync();
await fireFoxContainer.StartAsync();
await chromeContainer.StartAsync();
var connectionsString = "http://localhost:" + hubContainer.GetMappedPublicPort(4444);
Console.WriteLine("connectionsString = " + connectionsString);
WebDriverUrl = connectionsString;
}
}