Skip to content

Commit

Permalink
Add method to navigate to URI + downloading test workaround +semver: …
Browse files Browse the repository at this point in the history
…feature (#226)

* Lowercase logging preference key

* Add method to navigate to URI + downloading test workaround

* Try to stabilize GeoLocation test
  • Loading branch information
mialeska authored Jan 11, 2023
1 parent 66b9074 commit 80513d8
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 5 deletions.
6 changes: 6 additions & 0 deletions Aquality.Selenium/src/Aquality.Selenium/Aquality.Selenium.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions Aquality.Selenium/src/Aquality.Selenium/Browsers/Browser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,15 @@ public void GoTo(string url)
Navigate().GoToUrl(url);
}

/// <summary>
/// Navigates to desired URL.
/// </summary>
/// <param name="url">Desired URL.</param>
public void GoTo(Uri url)
{
Navigate().GoToUrl(url);
}

/// <summary>
/// Navigates back.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ protected void SetLoggingPreferences(DriverOptions options)
{
foreach (var preference in LoggingPreferences)
{
options.SetLoggingPreference(preference.Key, preference.Value);
options.SetLoggingPreference(preference.Key.ToLower(), preference.Value);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ private static void CheckGeolocationOverride(Action<double?, double?, double?> s
Assert.AreEqual(LongitudeForOverride, locationForm.Longitude, "Longitude should match to override value");

clearAction();
AqualityServices.Browser.WaitForPageToLoad();
AqualityServices.Browser.Refresh();
locationForm.DetectBrowserGeolocation();
Assert.AreEqual(defaultLatitude, locationForm.Latitude, "Latitude should match to default");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,22 @@ public void Should_BePossibleTo_DownloadTextFile()
var lblFileContent = AqualityServices.Get<IElementFactory>().GetLabel(By.XPath("//pre"), "text file content");
Assert.False(FileDownloadHelper.IsFileDownloaded(filePath, lblFileContent), $"file {filePath} should not exist before downloading");

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

browser.Driver.SwitchTo().Window(tabs[1]);
browser.Tabs().SwitchToLastTab();
downloaderForm.Open();
downloaderForm.GetDownloadLink(fileName).JsActions.ClickAndWait();
browser.Driver.SwitchTo().Window(tabs[0]);
var downloadLink = downloaderForm.GetDownloadLink(fileName);
if (downloadLink.State.IsDisplayed)
{
downloadLink.JsActions.ClickAndWait();
}
else
{
browser.GoTo(new Uri($"{downloaderForm.Url}/{fileName}"));
}

browser.Tabs().SwitchToTab(oldWindowHandle);
bool condition() => FileDownloadHelper.IsFileDownloaded(filePath, lblFileContent);
var message = $"file {filePath} was not downloaded";
try
Expand Down

0 comments on commit 80513d8

Please sign in to comment.