Skip to content

Commit 9fc72f2

Browse files
unknownunknown
authored andcommitted
Fixes the usage of partial urls with .Get
1 parent a19fd50 commit 9fc72f2

File tree

1 file changed

+11
-12
lines changed

1 file changed

+11
-12
lines changed

Selenium/WebDriver.cs

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -521,7 +521,7 @@ public string BaseUrl {
521521
return _baseUrl;
522522
}
523523
set {
524-
_baseUrl = value.TrimEnd('/') + '/';
524+
_baseUrl = value.TrimEnd('/');
525525
}
526526
}
527527

@@ -540,25 +540,24 @@ public bool Get(string url, int timeout = -1, bool raise = true) {
540540
if (string.IsNullOrEmpty(url))
541541
throw new Errors.ArgumentError("Argument 'url' cannot be null.");
542542

543-
if (timeout > 0)
543+
if (timeout > 0){
544544
session.timeouts.PageLoad = timeout;
545+
session.Send(RequestMethod.POST, "/timeouts", "type", "page load", "ms", timeout);
546+
}
545547

546-
int idx = url.IndexOf(":");
547-
if (idx == -1) {
548+
int idx = url.IndexOf("/");
549+
if (idx == 0) {
548550
//relative url
549551
if (_baseUrl == null)
550552
throw new Errors.ArgumentError("Base URL not defined. Define a base URL or use a full URL.");
551-
url = string.Concat(_baseUrl, url.TrimStart('/'));
553+
url = string.Concat(_baseUrl, url);
552554
} else {
553555
//absolute url
554-
idx = url.IndexOf("://");
556+
idx = url.IndexOf('/', idx + 3);
555557
if (idx != -1) {
556-
idx = url.IndexOf('/', idx + 3);
557-
if (idx != -1) {
558-
_baseUrl = url.Substring(0, idx).TrimEnd('/') + '/';
559-
} else {
560-
_baseUrl = url.TrimEnd('/') + '/';
561-
}
558+
_baseUrl = url.Substring(0, idx - 1);
559+
} else {
560+
_baseUrl = url;
562561
}
563562
}
564563

0 commit comments

Comments
 (0)