Skip to content

Commit 80513d8

Browse files
authored
Add method to navigate to URI + downloading test workaround +semver: feature (#226)
* Lowercase logging preference key * Add method to navigate to URI + downloading test workaround * Try to stabilize GeoLocation test
1 parent 66b9074 commit 80513d8

File tree

5 files changed

+30
-5
lines changed

5 files changed

+30
-5
lines changed

Aquality.Selenium/src/Aquality.Selenium/Aquality.Selenium.xml

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Aquality.Selenium/src/Aquality.Selenium/Browsers/Browser.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,15 @@ public void GoTo(string url)
171171
Navigate().GoToUrl(url);
172172
}
173173

174+
/// <summary>
175+
/// Navigates to desired URL.
176+
/// </summary>
177+
/// <param name="url">Desired URL.</param>
178+
public void GoTo(Uri url)
179+
{
180+
Navigate().GoToUrl(url);
181+
}
182+
174183
/// <summary>
175184
/// Navigates back.
176185
/// </summary>

Aquality.Selenium/src/Aquality.Selenium/Configurations/WebDriverSettings/DriverSettings.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ protected void SetLoggingPreferences(DriverOptions options)
182182
{
183183
foreach (var preference in LoggingPreferences)
184184
{
185-
options.SetLoggingPreference(preference.Key, preference.Value);
185+
options.SetLoggingPreference(preference.Key.ToLower(), preference.Value);
186186
}
187187
}
188188

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ private static void CheckGeolocationOverride(Action<double?, double?, double?> s
134134
Assert.AreEqual(LongitudeForOverride, locationForm.Longitude, "Longitude should match to override value");
135135

136136
clearAction();
137+
AqualityServices.Browser.WaitForPageToLoad();
137138
AqualityServices.Browser.Refresh();
138139
locationForm.DetectBrowserGeolocation();
139140
Assert.AreEqual(defaultLatitude, locationForm.Latitude, "Latitude should match to default");

Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/Usecases/FileDownloadingTests.cs

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,22 @@ public void Should_BePossibleTo_DownloadTextFile()
2424
var lblFileContent = AqualityServices.Get<IElementFactory>().GetLabel(By.XPath("//pre"), "text file content");
2525
Assert.False(FileDownloadHelper.IsFileDownloaded(filePath, lblFileContent), $"file {filePath} should not exist before downloading");
2626

27+
var oldWindowHandle = browser.Tabs().CurrentTabHandle;
2728
browser.ExecuteScriptFromFile("Resources.OpenUrlInNewWindow.js", downloaderForm.Url);
28-
var tabs = new List<string>(AqualityServices.Browser.Driver.WindowHandles);
2929

30-
browser.Driver.SwitchTo().Window(tabs[1]);
30+
browser.Tabs().SwitchToLastTab();
3131
downloaderForm.Open();
32-
downloaderForm.GetDownloadLink(fileName).JsActions.ClickAndWait();
33-
browser.Driver.SwitchTo().Window(tabs[0]);
32+
var downloadLink = downloaderForm.GetDownloadLink(fileName);
33+
if (downloadLink.State.IsDisplayed)
34+
{
35+
downloadLink.JsActions.ClickAndWait();
36+
}
37+
else
38+
{
39+
browser.GoTo(new Uri($"{downloaderForm.Url}/{fileName}"));
40+
}
41+
42+
browser.Tabs().SwitchToTab(oldWindowHandle);
3443
bool condition() => FileDownloadHelper.IsFileDownloaded(filePath, lblFileContent);
3544
var message = $"file {filePath} was not downloaded";
3645
try

0 commit comments

Comments
 (0)