Skip to content

Commit 5bc9fb2

Browse files
authored
[DevTools][Emulation] Handling of DevTools: emulate GeoLocation, Device, Media, UserAgent (#214) +semver: feature
1 parent cd15fd0 commit 5bc9fb2

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

Aquality.Selenium/src/Aquality.Selenium/Browsers/DevToolsHandling.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,9 @@ public DevToolsSession GetDevToolsSession()
8181
public DevToolsSession GetDevToolsSession(int protocolVersion)
8282
{
8383
Logger.Info("loc.browser.devtools.session.get", protocolVersion);
84-
return devToolsProvider.GetDevToolsSession(protocolVersion);
84+
var session = devToolsProvider.GetDevToolsSession(protocolVersion);
85+
wasDevToolsSessionClosed = false;
86+
return session;
8587
}
8688

8789
/// <summary>

Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/DevToolsEmulationTests.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
using Aquality.Selenium.Browsers;
2-
using Aquality.Selenium.Elements.Interfaces;
32
using Aquality.Selenium.Tests.Integration.TestApp.ManyTools.Forms;
43
using Aquality.Selenium.Tests.Integration.TestApp.MyLocation;
54
using Aquality.Selenium.Tests.Integration.TestApp.TheInternet.Forms;

README.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,15 @@ Assert.DoesNotThrowAsync(() => browser.Network.StartMonitoring());
6161
```
6262
see more examples at [NetworkHandlingTests](Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/NetworkHandlingTests.cs).
6363

64-
7. Quit browser at the end:
64+
7. Emulate GeoLocation, Device, Touch, Media, UserAgent overrides, Disable script execution and more using DevTools extensions:
65+
```csharp
66+
const double latitude = 35.8235;
67+
const double longitude = -78.8256;
68+
const double accuracy = 0.97;
69+
Assert.DoesNotThrowAsync(() => DevTools.SetGeoLocationOverride(latitude, longitude, accuracy), "Should be possible to override geoLocation")
70+
```
71+
72+
8. Quit browser at the end:
6573
```csharp
6674
browser.Quit();
6775
```

0 commit comments

Comments
 (0)