public void TestUpdateSuggestions() { SeleniumExtensions.ExecuteOnMultipleBrowsers(driver => { SignInHelper.SignInWithId(driver); var gameRows = TableHelper.FindGameRows(driver).ToArray(); Console.WriteLine("Updating HLTB correlation..."); DialogHelper.TestDialog(driver, gameRows[0].FindElement(By.ClassName(SiteConstants.RowWrongGameAnchorClass)), SiteConstants.HltbUpdateModalId, () => { driver.FindElement(By.Id(SiteConstants.HltbUpdateInputId)).SetText("123"); driver.FindElement(By.Id(SiteConstants.HltbUpdateSubmitButtonId)).Click(); }); Console.WriteLine("Waiting for correlation suggestion to be submitted..."); driver.WaitUntil(d => TableHelper.ParseGameRow(driver, gameRows[0]).UpdateState == UpdateState.Submitted, "Could not verify successful correlation submission"); Console.WriteLine("Suggesting non-game..."); DialogHelper.TestDialog(driver, gameRows[1].FindElement(By.ClassName(SiteConstants.RowVerifyGameAnchorId)), SiteConstants.NonGameUpdateModalId, () => { driver.FindElement(By.Id(SiteConstants.NonGameUpdateButtonId)).Click(); }); Console.WriteLine("Waiting for non-game suggestion to be submitted..."); driver.WaitUntil(d => { var gameInfo = TableHelper.ParseGameRow(driver, gameRows[1]); return(gameInfo.UpdateState == UpdateState.Submitted && !gameInfo.Included); }, "Could not verify successful non-game submission"); }); }
public void TestTextFilter() { SeleniumExtensions.ExecuteOnMultipleBrowsers(driver => { SignInHelper.SignInWithId(driver); Console.WriteLine("Setting filter to include two games..."); var filter = "in"; FilterHelper.SetTextFilter(driver, filter); driver.WaitUntil(d => GameSummaryHelper.GetGameCount(driver) == 2, Invariant($"Could not verify filter {filter}")); AssertActiveFilterNotifications(driver, true); CollectionAssert.AssertEqualSets(new[] { GameConstants.RoninSteamName, GameConstants.GodsWillBeWatchingSteamName }, TableHelper.ParseGameTable(driver).Select(g => g.SteamName), Invariant($"Could not verify filter {filter}")); Console.WriteLine("Setting filter to exclude all games..."); filter = Guid.NewGuid().ToString(); FilterHelper.SetTextFilter(driver, filter); driver.WaitUntil(d => GameSummaryHelper.GetGameCount(driver) == 0, Invariant($"Could not verify filter {filter}")); AssertActiveFilterNotifications(driver, true); Console.WriteLine("Clearing filter..."); FilterHelper.ClearTextFilter(driver); driver.WaitUntil(d => GameSummaryHelper.GetGameCount(driver) == 3, "Could not verify cleared filter"); AssertActiveFilterNotifications(driver, false); }); }
private static void AssertSurvival(IWebDriver driver, Gender gender, int birthYear, int weeklyPlaytime, PlayStyle playStyle, bool expectSurvival) { SignInHelper.SignInWithId(driver, UserConstants.SampleSteamId); SurvivalHelper.CalculateSurvival(driver, gender, birthYear, weeklyPlaytime, playStyle); Console.WriteLine("Parsing backlog completion date..."); var backlogCompletion = TestUtil.ParseBrowserDate(driver, driver.FindElement(By.Id(SiteConstants.SurvivalBacklogCompletionLabelId)).Text); Console.WriteLine("Parsing time of death date..."); var timeOfDeath = TestUtil.ParseBrowserDate(driver, driver.FindElement(By.Id(SiteConstants.SurvivalTimeOfDeathLabelId)).Text); Console.WriteLine("Asserting expected results..."); bool survival = timeOfDeath >= backlogCompletion; if (expectSurvival) { Assert.IsTrue(survival, "Expected time of death to come after backlog completion"); Assert.IsTrue(driver.FindElement(By.Id(SiteConstants.SurvivalSuccessImgId)).Displayed, "Expected backlog completion success"); } else { Assert.IsFalse(survival, "Expected time of death to come before backlog completion"); Assert.IsTrue(driver.FindElement(By.Id(SiteConstants.SurvivalFailureImgId)).Displayed, "Expected backlog completion failure"); } }
public void TestSignInWithNoGames() { SeleniumExtensions.ExecuteOnMultipleBrowsers(driver => { SignInHelper.SignInWithId(driver, UserConstants.SampleNoGamesUserId, WaitType.None); driver.WaitUntilElementIsVisible(By.Id(SiteConstants.EmptyLibraryDivId), "Could not locate empty library notification"); }); }
public void TestTableEntries() { SeleniumExtensions.ExecuteOnMultipleBrowsers(driver => { SignInHelper.SignInWithId(driver); AssertHltbsUserTable(TableHelper.ParseGameTable(driver), false); }); }
public void TestMobileTableEntries() { SeleniumExtensions.ExecuteOnMultipleBrowsers(driver => { SignInHelper.SignInWithId(driver); AssertHltbsUserTable(TableHelper.ParseGameTable(driver), true); }, Browsers.Nexus7Chrome); }
public void TestSignInWithInvalidUsername() { SeleniumExtensions.ExecuteOnMultipleBrowsers(driver => { SignInHelper.SignInWithId(driver, Guid.NewGuid().ToString(), WaitType.None); driver.WaitUntilElementIsVisible(By.Id(SiteConstants.LoginErrorDivId), "Could not locate login error notification"); }); }
public void TestPageLinks() { SeleniumExtensions.ExecuteOnMultipleBrowsers(driver => { SignInHelper.SignInWithId(driver); AssertPageLinks(driver); }); }
public void TestProperLinks() { SeleniumExtensions.ExecuteOnMultipleBrowsers(driver => { SignInHelper.SignInWithId(driver, UserConstants.SampleSteamId); AssertInternalLinks(driver); AssertExternalLinks(driver); }, Browsers.Chrome | Browsers.Firefox); //IE behaves strangely and it doesn't really matter as these links are simple hrefs }
public void TestMobileRenderedCharts() { SeleniumExtensions.ExecuteOnMultipleBrowsers(driver => { SignInHelper.SignInWithId(driver); TestRenderedCharts(driver); TestSlicers(driver); }, Browsers.IPhone); }
public void TestSignInWithSteamId64() { SeleniumExtensions.ExecuteOnMultipleBrowsers(driver => { SignInHelper.SignInWithId(driver, UserConstants.SampleSteam64Id.ToString(CultureInfo.InvariantCulture)); AssertPersonaDetails(driver, UserConstants.SamplePersonaName, UserConstants.SamplePersonaAvatarUuid); Console.WriteLine("Asserting the imputed values notification is displayed..."); driver.FindElement(By.Id(SiteConstants.ImputedValuesNotificationDivId)); }); }
public void TestMobileLinks() { // If this test fails, try clicking via JS https://stackoverflow.com/a/17569061/67824 SeleniumExtensions.ExecuteOnMultipleBrowsers(driver => { SignInHelper.SignInWithId(driver); AssertPageLinks(driver); AssertInternalLinks(driver); AssertExternalLinks(driver); }, Browsers.OptimusL70Chrome); }
public void TestGameSummary() { SeleniumExtensions.ExecuteOnMultipleBrowsers(driver => { SignInHelper.SignInWithId(driver); Assert.AreEqual(UserConstants.HltbUserGameCount, GameSummaryHelper.GetGameCount(driver), "incorrect game count"); Assert.AreEqual(UserConstants.HltbUserExcludedGameCount, GetExcludedGameCount(driver), "incorrect excluded game count"); AssertValidPlaytimes(driver); AssertValidPercentages(driver); }); }
public void TestTableSort() { SeleniumExtensions.ExecuteOnMultipleBrowsers(driver => { SignInHelper.SignInWithId(driver); TestColumnSort(driver, SiteConstants.SteamNameTitle, g => g.SteamName); TestColumnSort(driver, SiteConstants.SteamPlaytimeTitle, g => g.SteamPlaytime); TestColumnSort(driver, SiteConstants.MainPlaytimeTitle, g => g.MainPlaytime); TestColumnSort(driver, SiteConstants.ExtrasPlaytimeTitle, g => g.ExtrasPlaytime); TestColumnSort(driver, SiteConstants.CompletionistPlaytimeTitle, g => g.CompletionistPlaytime); TestColumnSort(driver, SiteConstants.HltbNameTitle, g => g.HltbName); }); }
public void TestNotifications() { SeleniumExtensions.ExecuteOnMultipleBrowsers(driver => { driver.Url = SiteConstants.LocalDeploymentUrl; TooltipHelper.AssertTooltip(driver, By.Id(SiteConstants.ProfileIdTooltip), "steamcommunity.com/id/[ID]"); SignInHelper.SignInWithId(driver); TooltipHelper.AssertTooltip(driver, By.Id(SiteConstants.PlaytimeTooltip), "As recorded by Steam"); TooltipHelper.AssertTooltip(driver, By.Id(SiteConstants.ExcludedGamesTooltip), "non-game apps are excluded"); TooltipHelper.AssertTooltip(driver, By.Id(SiteConstants.SteamPlaytimeTitle), "Current Steam playtime"); TooltipHelper.AssertTooltip(driver, By.Id(SiteConstants.MainPlaytimeTitle), "main objectives"); TooltipHelper.AssertTooltip(driver, By.Id(SiteConstants.ExtrasPlaytimeTitle), "extra objectives"); TooltipHelper.AssertTooltip(driver, By.Id(SiteConstants.CompletionistPlaytimeTitle), "all possible objectives"); }); }
public void TestPageNavigation() { SeleniumExtensions.ExecuteOnMultipleBrowsers(driver => { SignInHelper.SignInWithId(driver, UserConstants.SampleSteamId); Assert.IsFalse(NavigationEnabled(driver.FindElement(By.Id(SiteConstants.FirstPageAnchorId))), "Expected first page button to be disabled"); Assert.IsFalse(NavigationEnabled(driver.FindElement(By.Id(SiteConstants.PreviousPageAnchorId))), "Expected previous page button to be disabled"); var firstPageGames = TableHelper.ParseGameTable(driver); Navigate(driver, SiteConstants.NextPageAnchorId); var secondPageGames = TableHelper.ParseGameTable(driver); CollectionAssert.AssertDistinctSets(firstPageGames, secondPageGames, "Common games found in first and second table pages"); Navigate(driver, SiteConstants.FixedPageAnchorIdPrefix + "4"); var fourthPageGames = TableHelper.ParseGameTable(driver); CollectionAssert.AssertDistinctSets(firstPageGames, fourthPageGames, "Common games found in first and fourth table pages"); CollectionAssert.AssertDistinctSets(secondPageGames, fourthPageGames, "Common games found in second and fourth game pages"); Navigate(driver, SiteConstants.LastPageAnchorId); var lastPageGames = TableHelper.ParseGameTable(driver); CollectionAssert.AssertDistinctSets(firstPageGames, lastPageGames, "Common games found in first and last table pages"); CollectionAssert.AssertDistinctSets(secondPageGames, lastPageGames, "Common games found in second and last table pages"); CollectionAssert.AssertDistinctSets(fourthPageGames, lastPageGames, "Common games found in fourth and last table pages"); Assert.IsFalse(NavigationEnabled(driver.FindElement(By.Id(SiteConstants.NextPageAnchorId))), "Expected last page button to be disabled"); Assert.IsFalse(NavigationEnabled(driver.FindElement(By.Id(SiteConstants.LastPageAnchorId))), "Expected next page button to be disabled"); Navigate(driver, SiteConstants.PreviousPageAnchorId); var secondLastPageGames = TableHelper.ParseGameTable(driver); CollectionAssert.AssertDistinctSets(firstPageGames, secondLastPageGames, "Common games found in first and second last table pages"); CollectionAssert.AssertDistinctSets(secondPageGames, secondLastPageGames, "Common games found in second and second last table pages"); CollectionAssert.AssertDistinctSets(fourthPageGames, secondLastPageGames, "Common games found in fourth and second last table pages"); CollectionAssert.AssertDistinctSets(lastPageGames, secondLastPageGames, "Common games found in last and second last table pages"); Navigate(driver, SiteConstants.FirstPageAnchorId); CollectionAssert.AssertEqualSequences(firstPageGames, TableHelper.ParseGameTable(driver), "Inconsistent games in first table page"); foreach (var gamesPerPage in SiteConstants.GamesPerPageOptions) { new SelectElement(driver.FindElement(By.Id(SiteConstants.GamesPerPageSelectId))).SelectByValue(gamesPerPage.ToString(CultureInfo.InvariantCulture)); Assert.AreEqual(gamesPerPage, GetTablePageCount(driver), "Unexpected page game count"); } }); }
public void TestAdvancedFilter() { SeleniumExtensions.ExecuteOnMultipleBrowsers(driver => { SignInHelper.SignInWithId(driver); Console.WriteLine("Setting advanced filter by release year..."); FilterHelper.SetAdvancedFilter(driver, 2015, 2016); driver.WaitUntil(d => GameSummaryHelper.GetGameCount(driver) == 2, "Could not verify release year advanced filter"); CollectionAssert.AssertEqualSets(new[] { GameConstants.RoninSteamName, GameConstants.AFistfulOfGunSteamName }, TableHelper.ParseGameTable(driver).Select(g => g.SteamName), "Could not verify release year advanced filter"); AssertActiveFilterNotifications(driver, true); FilterHelper.ClearAdvancedFilter(driver); driver.WaitUntil(d => GameSummaryHelper.GetGameCount(driver) == 3, "Could not verify cleared advanced filter"); AssertActiveFilterNotifications(driver, false); Console.WriteLine("Setting advanced filter by Metacritic score..."); FilterHelper.SetAdvancedFilter(driver, 2014, -1, 60, 70); driver.WaitUntil(d => GameSummaryHelper.GetGameCount(driver) == 1, "Could not verify metacritic advanced filter"); CollectionAssert.AssertEqualSets(new[] { GameConstants.GodsWillBeWatchingSteamName }, TableHelper.ParseGameTable(driver).Select(g => g.SteamName), "Could not verify metacritic advanced filter"); AssertActiveFilterNotifications(driver, true); Console.WriteLine("Setting advanced filter by genre..."); FilterHelper.SetAdvancedFilter(driver, -1, -1, -1, -1, new [] { GameConstants.ActionGenre }); driver.WaitUntil(d => GameSummaryHelper.GetGameCount(driver) == 0, "Could not verify metacritic+genre advanced filter"); AssertActiveFilterNotifications(driver, true); Console.WriteLine("Clearing filter (externally)..."); FilterHelper.ClearAdvancedFilterExternally(driver); driver.WaitUntil(d => GameSummaryHelper.GetGameCount(driver) == 3, "Could not verify externally cleared advanced filter"); AssertActiveFilterNotifications(driver, false); Console.WriteLine("Setting combined filter and advanced filter..."); FilterHelper.SetAdvancedFilter(driver, -1, -1, -1, -1, new[] { GameConstants.ActionGenre }); driver.WaitUntil(d => GameSummaryHelper.GetGameCount(driver) == 2, "Could not verify genre advanced filter"); FilterHelper.SetTextFilter(driver, "gun"); driver.WaitUntil(d => GameSummaryHelper.GetGameCount(driver) == 1, "Could not verify combined filter and advanced filter"); CollectionAssert.AssertEqualSets(new[] { GameConstants.AFistfulOfGunSteamName }, TableHelper.ParseGameTable(driver).Select(g => g.SteamName), "Could not verify combined filter and advanced filter"); }); }
public void TestShareLinks() { SeleniumExtensions.ExecuteOnMultipleBrowsers(driver => { var isInternetExplorer = driver is InternetExplorerDriver; SignInHelper.SignInWithId(driver); LinkHelper.AssertExternalLink(driver, SiteConstants.FacebookShareAnchorId, FacebookShareTitle, newWindow: true, dismissAlertOnClose: isInternetExplorer); LinkHelper.AssertExternalLink(driver, SiteConstants.TwitterShareAnchorId, TwitterShareTitle, newWindow: true); LinkHelper.AssertExternalLink(driver, SiteConstants.RedditShareAnchorId, RedditShareTitle, newWindow: true); SurvivalHelper.CalculateSurvival(driver, Gender.Female, DateTime.Now.Year - 20, 10, PlayStyle.Extras); LinkHelper.AssertExternalLink(driver, SiteConstants.SurvivalFacebookShareAnchorId, FacebookShareTitle, newWindow: true, dismissAlertOnClose: isInternetExplorer); LinkHelper.AssertExternalLink(driver, SiteConstants.SurvivalTwitterShareAnchorId, TwitterShareTitle, newWindow: true); LinkHelper.AssertExternalLink(driver, SiteConstants.SurvivalRedditShareAnchorId, RedditShareTitle, newWindow: true); }); }
public void TestTableInclusion() { SeleniumExtensions.ExecuteOnMultipleBrowsers(driver => { SignInHelper.SignInWithId(driver); var originalMain = GameSummaryHelper.GetRemainingMainPlaytime(driver); var originalExtras = GameSummaryHelper.GetRemainingExtrasPlaytime(driver); var originalCompletionist = GameSummaryHelper.GetRemainingCompletionistPlaytime(driver); var inclusionCheckboxes = TableHelper.FindTableBody(driver).FindElements(By.ClassName(SiteConstants.RowIncludedCheckboxClass)); Console.WriteLine("Excluding a game..."); inclusionCheckboxes.First().Click(); Assert.AreEqual(2, GameSummaryHelper.GetGameCount(driver), "Expected exclusion of game to reduce game count"); var mainPostExclusion = GameSummaryHelper.GetRemainingMainPlaytime(driver); var extrasPostExclusion = GameSummaryHelper.GetRemainingExtrasPlaytime(driver); var completionistPostExclusion = GameSummaryHelper.GetRemainingCompletionistPlaytime(driver); Assert.IsTrue(mainPostExclusion < originalMain, "Expected exclusion of game to reduce original remaining main playtime"); Assert.IsTrue(extrasPostExclusion < originalExtras, "Expected exclusion of game to reduce original remaining main playtime"); Assert.IsTrue(completionistPostExclusion < originalCompletionist, "Expected exclusion of game to reduce original remaining main playtime"); Console.WriteLine("Excluding remaining games..."); foreach (var inclusionCheckbox in inclusionCheckboxes.Skip(1)) { inclusionCheckbox.Click(); } Assert.AreEqual(0, GameSummaryHelper.GetGameCount(driver), "Expected zero game count when all games are excluded"); Assert.AreEqual(TimeSpan.Zero, GameSummaryHelper.GetRemainingMainPlaytime(driver), "Expected zero main remaining playtime"); Assert.AreEqual(TimeSpan.Zero, GameSummaryHelper.GetRemainingExtrasPlaytime(driver), "Expected zero extras remaining playtime"); Assert.AreEqual(TimeSpan.Zero, GameSummaryHelper.GetRemainingCompletionistPlaytime(driver), "Expected zero completionist remaining playtime"); }); }