Skip to content

Commit

Permalink
[dotnet] have url property setter call navigation method instead of t…
Browse files Browse the repository at this point in the history
…he other way around
  • Loading branch information
titusfortner committed May 17, 2024
1 parent 7f67d6e commit 2ddc605
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 13 deletions.
15 changes: 13 additions & 2 deletions dotnet/src/webdriver/Navigator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
// </copyright>

using System;
using System.Collections.Generic;

namespace OpenQA.Selenium
{
Expand Down Expand Up @@ -58,7 +59,17 @@ public void Forward()
/// <param name="url">String of where you want the browser to go to</param>
public void GoToUrl(string url)
{
this.driver.Url = url;
if (url == null)
{
throw new ArgumentNullException(nameof(url), "URL cannot be null.");
}

Dictionary<string, object> parameters = new Dictionary<string, object>
{
{ "url", url }
};
this.driver.InternalExecute(DriverCommand.Get, parameters);

}

/// <summary>
Expand All @@ -72,7 +83,7 @@ public void GoToUrl(Uri url)
throw new ArgumentNullException(nameof(url), "URL cannot be null.");
}

this.driver.Url = url.ToString();
this.GoToUrl(url.ToString());
}

/// <summary>
Expand Down
12 changes: 1 addition & 11 deletions dotnet/src/webdriver/WebDriver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -109,17 +109,7 @@ public string Url
return commandResponse.Value.ToString();
}

set
{
if (value == null)
{
throw new ArgumentNullException(nameof(value), "Argument 'url' cannot be null.");
}

Dictionary<string, object> parameters = new Dictionary<string, object>();
parameters.Add("url", value);
this.Execute(DriverCommand.Get, parameters);
}
set => new Navigator(this).GoToUrl(value);
}

/// <summary>
Expand Down

0 comments on commit 2ddc605

Please sign in to comment.