This repository has been archived by the owner on Feb 6, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathRemoteBrowserMobProxyFunctionalTests.cs
50 lines (43 loc) · 1.79 KB
/
RemoteBrowserMobProxyFunctionalTests.cs
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
using System;
using System.Linq;
using NUnit.Framework;
using OpenQA.Selenium;
using OpenQA.Selenium.Chrome;
using OpenQA.Selenium.Remote;
namespace RemoteBrowserMobProxy.Tests
{
[Ignore("Prevent this from being picked up by GitHub unit tests pipeline")]
internal class RemoteBrowserMobProxyFunctionalTests
{
private IWebDriver _driver;
private IRemoteBrowserMobProxyClient _proxyClient;
[SetUp]
public void Setup ()
{
_proxyClient = new RemoteBrowserMobProxyClient(new Uri("http://localhost:58080"));
_proxyClient.NewRemoteBrowserMobProxyInstance(8081);
ChromeOptions driverOptions = new ChromeOptions();
//proxy port 8081 inside docker container is exposed to host on port 58081
Proxy proxy = new Proxy { Kind = ProxyKind.Manual, IsAutoDetect = false, SslProxy = "http://browsermobproxy:8081" };
driverOptions.Proxy = proxy;
driverOptions.AddArgument("--start-maximized");
driverOptions.AddArgument("--ignore-certificate-errors");
_driver = new RemoteWebDriver(new Uri("http://localhost:4444/wd/hub/"), driverOptions.ToCapabilities(), TimeSpan.FromMinutes(3));
}
[Test]
public void CaptureNetworkTrafficTest()
{
var proxyInstance = _proxyClient.RemoteBrowserMobProxyInstances().First();
proxyInstance.CreateHar();
_driver.Navigate().GoToUrl(new Uri("https://hub.docker.com/"));
// captured network traffic
var harContent = proxyInstance.GetHarContent();
}
[TearDown]
public void TearDown()
{
_proxyClient.RemoteBrowserMobProxyInstances().ToList().ForEach(p=>p.Dispose());
_driver.Dispose();
}
}
}