diff --git a/src/Core/Riganti.Selenium.Core/BrowserWrapper.cs b/src/Core/Riganti.Selenium.Core/BrowserWrapper.cs
index 8dee6ab7..6818f68c 100644
--- a/src/Core/Riganti.Selenium.Core/BrowserWrapper.cs
+++ b/src/Core/Riganti.Selenium.Core/BrowserWrapper.cs
@@ -89,7 +89,7 @@ public void SetCssSelector()
///
/// Gives path of url of active browser tab.
///
- public string CurrentUrlPath => new Uri(CurrentUrl).GetLeftPart(UriPartial.Path);
+ public string CurrentUrlPath => new Uri(CurrentUrl).GetComponents(UriComponents.PathAndQuery | UriComponents.Fragment, UriFormat.UriEscaped);
diff --git a/src/Tests/Riganti.Selenium.Core.UnitTests/BrowserWrapperTests.cs b/src/Tests/Riganti.Selenium.Core.UnitTests/BrowserWrapperTests.cs
new file mode 100644
index 00000000..3d857759
--- /dev/null
+++ b/src/Tests/Riganti.Selenium.Core.UnitTests/BrowserWrapperTests.cs
@@ -0,0 +1,37 @@
+using System.Collections.Generic;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+using OpenQA.Selenium;
+using Riganti.Selenium.Core.UnitTests.Mock;
+using Selenium.Core.UnitTests;
+
+namespace Riganti.Selenium.Core.UnitTests;
+
+[TestClass]
+public class BrowserWrapperTests : MockingTest
+{
+ public TestContext TestContext { get; set; }
+
+ [TestMethod]
+ public void CurrentUrlPath_NoEscapedCharactersTest()
+ {
+ var driverMock = new MockIWebDriver
+ {
+ FindElementsAction = () => new List() { new MockIWebElement() { TagName = "a" } },
+ Url = "https://localhost:12345/path1/path2?query=1#fragment"
+ };
+ var browser = CreateMockedIBrowserWrapper(driverMock);
+ Assert.AreEqual("/path1/path2?query=1#fragment", browser.CurrentUrlPath);
+ }
+
+ [TestMethod]
+ public void CurrentUrlPath_WithEscapedCharatersTest()
+ {
+ var driverMock = new MockIWebDriver
+ {
+ FindElementsAction = () => new List() { new MockIWebElement() { TagName = "a" } },
+ Url = "https://localhost:12345/path1/path2%20second%20part?query=1#fragment"
+ };
+ var browser = CreateMockedIBrowserWrapper(driverMock);
+ Assert.AreEqual("/path1/path2%20second%20part?query=1#fragment", browser.CurrentUrlPath);
+ }
+}
diff --git a/src/Tests/Riganti.Selenium.Core.UnitTests/Riganti.Selenium.Core.UnitTests.csproj b/src/Tests/Riganti.Selenium.Core.UnitTests/Riganti.Selenium.Core.UnitTests.csproj
index aa0e3385..21dad6bd 100644
--- a/src/Tests/Riganti.Selenium.Core.UnitTests/Riganti.Selenium.Core.UnitTests.csproj
+++ b/src/Tests/Riganti.Selenium.Core.UnitTests/Riganti.Selenium.Core.UnitTests.csproj
@@ -7,9 +7,9 @@
-
-
-
+
+
+
diff --git a/src/Tests/Riganti.Selenium.Core.UnitTests/SeleniumManagerTests.cs b/src/Tests/Riganti.Selenium.Core.UnitTests/SeleniumManagerTests.cs
index decc18c6..a41d397b 100644
--- a/src/Tests/Riganti.Selenium.Core.UnitTests/SeleniumManagerTests.cs
+++ b/src/Tests/Riganti.Selenium.Core.UnitTests/SeleniumManagerTests.cs
@@ -2,6 +2,7 @@
using System.Text.Json;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using OpenQA.Selenium;
+namespace Riganti.Selenium.Core.UnitTests;
[TestClass]
public class SeleniumManagerTests