public void Execute(DriverManager driver, TestStep step) { long order = step.Order; string wait = step.Wait != null ? step.Wait : ""; string size = ""; int total = 0; List <TestStep> steps = new List <TestStep>(); VerifyError err = new VerifyError(); size = driver.FindElement("xpath", "//pre").Text; size = size.Substring(size.IndexOf("Total Entities=") + 15); log.Info(size); try { total = Int32.Parse(size); } catch (Exception e) { log.Error("Expected data to be a numeral. Setting data to 0."); } if (total > 40000) { log.Info("Verification PASSED. Total Entities equals " + total); } else { log.Error("***Verification FAILED. " + total + " is not greater than 40,000 ***"); err.CreateVerificationError(step, "> 40,000", total.ToString()); } }
public void Execute(DriverManager driver, TestStep step) { long order = step.Order; string wait = step.Wait != null ? step.Wait : ""; int size = 0; int total; List <TestStep> steps = new List <TestStep>(); VerifyError err = new VerifyError(); if (step.Name.Equals("Verify Provider Count")) { try { total = Int32.Parse(step.Data); } catch (Exception e) { total = 500; log.Error("Expected data to be a numeral. Setting data to 500."); } size = driver.FindElements("xpath", "//div[contains(@class,'mvpd-item-groups')]//h2").Count; if (size >= total) { log.Info("Verification PASSED. Total Providers [" + size + "] is greater than " + total); } else { log.Error("***Verification FAILED. " + size + " is not greater than " + total + "***"); err.CreateVerificationError(step, "> " + total, size.ToString()); } } }
private static void CreateAndUpdateErrors(string errorMessage, string validatorName, List <VerifyError> errors, ValidatorType type = ValidatorType.BuildIn) { var error = new VerifyError { ErrorMessage = errorMessage, ValidatorName = validatorName, ViaValidatorType = type }; errors.Add(error); }
public void Execute(DriverManager driver, TestStep step) { long order = step.Order; string wait = step.Wait != null ? step.Wait : ""; List <TestStep> steps = new List <TestStep>(); IWebElement ele; string data = ""; IJavaScriptExecutor js = (IJavaScriptExecutor)driver.GetDriver(); VerifyError err = new VerifyError(); bool withinSeven = false; if (step.Name.Equals("Verify Countdown Clock Within 7 Days")) { if (DataManager.CaptureMap.ContainsKey("CURRENT")) { log.Info("Game date: " + DataManager.CaptureMap["CURRENT"]); if (DataManager.CaptureMap["CURRENT"].Equals("TODAY") || DataManager.CaptureMap["CURRENT"].Equals("TOMORROW")) { withinSeven = true; } else { var week = DateTime.Now.AddDays(+7); log.Info("Seven days from now : " + week.ToString("ddd, MMM d").ToUpper()); if (week >= DateTime.Parse(DataManager.CaptureMap["CURRENT"])) { log.Info("within week"); withinSeven = true; } else { log.Info("not within week"); withinSeven = false; } } } else { log.Info("No Key for CURRENT"); } if (withinSeven) { steps.Add(new TestStep(order, "Verify Countdown is Displayed", "", "verify_displayed", "xpath", "//div[contains(@class,'countdown-timer')]", wait)); TestRunner.RunTestSteps(driver, null, steps); steps.Clear(); } } else { throw new Exception("Test Step not found in script"); } }
public static VerifyFailure Create(string propertyName, string errorMessage) { var failure = new VerifyFailure(propertyName, errorMessage); var error = new VerifyError { ErrorMessage = errorMessage, ViaValidatorType = ValidatorType.Custom, ValidatorName = "System.ComponentModel.DataAnnotations.Validator" }; failure.Details.Add(error); return(failure); }
public void Execute(DriverManager driver, TestStep step) { long order = step.Order; string wait = step.Wait != null ? step.Wait : ""; IWebElement ele; int size = 0; string preview = ""; string subPreview = ""; string time = ""; string path = ""; bool live = false; List <TestStep> steps = new List <TestStep>(); VerifyError err = new VerifyError(); if (step.Name.Equals("Verify PVP Countdown Text")) { path = "//div[contains(@class,'pvp-expires')]/span"; preview = driver.FindElement("xpath", path).GetAttribute("innerText"); subPreview = preview.Substring(0, preview.Length - 1); if (preview.Contains("59:")) { time = "Preview Pass · 59:5"; } else { time = step.Data; } byte[] bytes = Encoding.Default.GetBytes(time); time = Encoding.UTF8.GetString(bytes); if (time.Equals(subPreview)) { log.Info("***Verification PASSED. Expected data [" + time + "] matches actual data [" + subPreview + "] ***"); } else { log.Error("***Verification FAILED. Expected data [" + time + "] does not match actual data [" + subPreview + "] ***"); err.CreateVerificationError(step, time, subPreview); } } else { throw new Exception("Test Step not found in script"); } }
public void Execute(DriverManager driver, TestStep step) { long order = step.Order; string wait = step.Wait != null ? step.Wait : ""; List <TestStep> steps = new List <TestStep>(); int size; int upper; string data = ""; VerifyError err = new VerifyError(); if (step.Name.Equals("Verify Scorechip Count")) { try { upper = Int32.Parse(step.Data); } catch (Exception e) { log.Error("Expected data to be a numeral. Setting data to 0."); upper = 0; } size = driver.FindElements("xpath", "//div[contains(@class,'score-chip')]").Count; if (size > 0 && size <= upper) { log.Info("Verification Passed. " + size + " is between 1 and " + upper); } else { err.CreateVerificationError(step, "Number Between 1 and " + upper.ToString(), size.ToString()); driver.TakeScreenshot(DataManager.CaptureMap["TEST_ID"] + "_verification_failure_" + DataManager.VerifyErrors.Count); } } else if (step.Name.Equals("Capture Team Info from Scorestrip")) { data = step.Data; steps.Add(new TestStep(order, "Capture Away Team Abbreviation", "AWAY_TEAM_ABB" + data, "capture", "xpath", "((//a[contains(@class,'score-chip')])[" + data + "]//div[@class='teams']//div[contains(@class,'abbreviation')])[1]", wait)); steps.Add(new TestStep(order, "Capture Away Team", "AWAY_TEAM" + data, "capture", "xpath", "((//a[contains(@class,'score-chip')])[" + data + "]//div[@class='teams']//div[contains(@class,' team')])[1]", wait)); steps.Add(new TestStep(order, "Capture Home Team Abbreviation", "HOME_TEAM_ABB" + data, "capture", "xpath", "((//a[contains(@class,'score-chip')])[" + data + "]//div[@class='teams']//div[contains(@class,'abbreviation')])[2]", wait)); steps.Add(new TestStep(order, "Capture Home Team", "HOME_TEAM" + data, "capture", "xpath", "((//a[contains(@class,'score-chip')])[" + data + "]//div[@class='teams']//div[contains(@class,' team')])[2]", wait)); TestRunner.RunTestSteps(driver, null, steps); steps.Clear(); } else { throw new Exception("Test Step not found in script"); } }
public void Execute(DriverManager driver, TestStep step) { long order = step.Order; string wait = step.Wait != null ? step.Wait : ""; string size = ""; string data = ""; string win = ""; int total = 0; int winner = 0; List <TestStep> steps = new List <TestStep>(); VerifyError err = new VerifyError(); if (step.Name.Equals("Capture Number of FB Entities")) { size = "//button[contains(@class,'expandable') and not(contains(@class,'expanded'))]"; total = driver.FindElements("xpath", size).Count; if (total != 0) { steps.Add(new TestStep(order, "Click Open Expandable", "", "click", "xpath", size, wait)); TestRunner.RunTestSteps(driver, null, steps); steps.Clear(); } winner = driver.FindElements("xpath", "//li[@class='sportOutrightView']").Count; if (winner > 1) { win = "//li[@class='sportOutrightView'][" + winner + "]"; } size = win + "//a[contains(@id,'event-selection') and not(contains(@class,'disabled'))]"; total = driver.FindElements("xpath", size).Count; data = step.Data; if (String.IsNullOrEmpty(data)) { data = "PLAYERS_LISTED"; } DataManager.CaptureMap[data] = total.ToString(); } else { throw new Exception("Test Step not found in script"); } }
public void Execute(DriverManager driver, TestStep step) { long order = step.Order; string wait = step.Wait != null ? step.Wait : ""; List <TestStep> steps = new List <TestStep>(); IWebElement ele; string data = ""; VerifyError err = new VerifyError(); string[] nascarGroups = { "CUP SERIES", "GANDER RV & OUTDOORS TRUCK SERIES", "XFINITY SERIES" }; if (step.Name.Equals("Verify Golf Groups")) { data = "//div[contains(@class,'scores-home-container')]//div[contains(@class,'active')]//ul"; steps.Add(new TestStep(order, "Open Conference Dropdown", "", "click", "xpath", "//a[@class='dropdown-menu-title']", wait)); steps.Add(new TestStep(order, "Verify Dropdown is Displayed", "", "verify_displayed", "xpath", data, wait)); TestRunner.RunTestSteps(driver, null, steps); steps.Clear(); data = data + "//li"; steps.Add(new TestStep(order, "Verify Number of Groups", "3", "verify_count", "xpath", data, wait)); TestRunner.RunTestSteps(driver, null, steps); steps.Clear(); var groups = driver.FindElements("xpath", data); for (int i = 0; i < groups.Count; i++) { if (nascarGroups[i].Equals(groups[i].GetAttribute("innerText"))) { log.Info("Success. " + nascarGroups[i] + " matches " + groups[i].GetAttribute("innerText")); } else { log.Error("***Verification FAILED. Expected data [" + nascarGroups[i] + "] does not match actual data [" + groups[i].GetAttribute("innerText") + "] ***"); err.CreateVerificationError(step, nascarGroups[i], groups[i].GetAttribute("innerText")); } } } else { throw new Exception("Test Step not found in script"); } }
public static VerifyResult VerifyOne(VerifiableMemberContext context) { if (context is null) { throw new ArgumentNullException(nameof(context)); } var annotations = context.Attributes .Where(a => a.GetType().IsDerivedFrom <ValidationAttribute>()) .Select(a => a as ValidationAttribute); var errors = new List <VerifyError>(); foreach (var annotation in annotations) { if (annotation is null) { continue; } if (annotation.IsValid(context.Value)) { continue; } var error = new VerifyError { ErrorMessage = annotation.ErrorMessage, ViaValidatorType = ValidatorType.Custom, ValidatorName = $"DataAnnotation {annotation.GetType().GetFriendlyName()} Validator" }; errors.Add(error); } if (!errors.Any()) { return(VerifyResult.Success); } var failure = new VerifyFailure(context.MemberName, $"There are multiple errors in this Member '{context.MemberName}'.", context.Value); return(new VerifyResult(failure)); }
public void Execute(DriverManager driver, TestStep step) { VerifyError err = new VerifyError(); long order = step.Order; string wait = step.Wait != null ? step.Wait : ""; List <string> standings = new List <string>(); List <TestStep> steps = new List <TestStep>(); Random random = new Random(); int total = 0; int size; string name = ""; IWebElement element; StringBuilder sb = new StringBuilder(); if (step.Name.Equals("Click and Capture Random Team By Division")) { name = "//div[contains(@class,'table-standings')][table//th[contains(.,'" + step.Data + "')]]//tbody/tr"; total = driver.FindElements("xpath", name).Count; total = random.Next(1, total + 1); steps.Add(new TestStep(order, "Capture Team from " + step.Data, "DIV_TEAM", "capture", "xpath", "(//div[contains(@class,'table-standings')][table//th[contains(.,'" + step.Data + "')]]//a[contains(@class,'entity-name')])[" + total + "]", wait)); steps.Add(new TestStep(order, "Click Team from " + step.Data, "", "click", "xpath", "(//div[contains(@class,'table-standings')][table//th[contains(.,'" + step.Data + "')]]//a[contains(@class,'entity-name')])[" + total + "]", wait)); TestRunner.RunTestSteps(driver, null, steps); steps.Clear(); } else if (step.Name.Equals("Capture Player Stat Leader by Number")) { steps.Add(new TestStep(order, "Capture Leader " + step.Data, "STAT_LEADER", "capture", "xpath", "(//div[contains(@class,'stat-leader-info')]/div[1])[" + step.Data + "]", wait)); steps.Add(new TestStep(order, "Capture Leader Team " + step.Data, "STAT_LEADER_TEAM", "capture", "xpath", "(//div[contains(@class,'stat-leader-info')]/div[@class='uc'])[" + step.Data + "]", wait)); TestRunner.RunTestSteps(driver, null, steps); steps.Clear(); name = DataManager.CaptureMap["STAT_LEADER"]; name = name.Substring(0, 1) + "." + name.Substring(name.IndexOf(" ")); sb.AppendLine(name); sb.Append(DataManager.CaptureMap["STAT_LEADER_TEAM"]); DataManager.CaptureMap["STAT_LEADER"] = sb.ToString(); } else { throw new Exception("Test Step not found in script"); } }
public void Execute(DriverManager driver, TestStep step) { JObject jsonValue; JObject def; long order = step.Order; string wait = step.Wait != null ? step.Wait : ""; List <TestStep> steps = new List <TestStep>(); string leaderboard = ""; IWebElement ele; VerifyError err = new VerifyError(); IJavaScriptExecutor js = (IJavaScriptExecutor)driver.GetDriver(); OpenQA.Selenium.Interactions.Actions actions = new OpenQA.Selenium.Interactions.Actions(driver.GetDriver()); string fileLocation = "https://api.foxsports.com/bifrost/v1/nascar/scoreboard/segment/2021" + step.Data + "?groupId=2&apikey=jE7yBJVRNAwdDesMgTzTXUUSx1It41Fq"; var jsonFile = new WebClient().DownloadString(fileLocation); var json = JObject.Parse(jsonFile); jsonValue = json; DataManager.CaptureMap["IND_EVENTID"] = json["currentSectionId"].ToString(); log.Info("Current Section ID from Bifrost: " + DataManager.CaptureMap["IND_EVENTID"]); foreach (JToken race in jsonValue["sectionList"]) { if (DataManager.CaptureMap["IND_EVENTID"] == race["id"].ToString()) { def = (JObject)(race.SelectToken("events") as JArray).First; DataManager.CaptureMap["IND_EVENT"] = def.Value <string>("title"); DataManager.CaptureMap["IND_TRACK"] = def.Value <string>("subtitle"); DataManager.CaptureMap["IND_LOC"] = def.Value <string>("subtitle2"); DataManager.CaptureMap["IND_TIME"] = def.Value <string>("eventTime"); DataManager.CaptureMap["IND_CHANNEL"] = def.Value <string>("tvStation"); if (def.ContainsKey("leaderboard")) { //(string) = def.Value<string>("$..leaderboard.title"); leaderboard = def.SelectToken("$..leaderboard.title").ToString(); log.Info(leaderboard); } } } }
public static IEnumerable <VerifyFailure> ConvertToVerifyFailures(this IList <ValidationFailure> originalFailures, Type typeOfValidator) { var failureHolding = new Dictionary <string, VerifyFailure>(); foreach (var originalFailure in originalFailures) { if (!failureHolding.TryGetValue(originalFailure.PropertyName, out var targetFailure)) { targetFailure = new VerifyFailure(originalFailure.PropertyName, $"There are multiple errors in this Member '{originalFailure.PropertyName}'.", originalFailure.AttemptedValue); failureHolding[originalFailure.PropertyName] = targetFailure; } var error = new VerifyError { ErrorMessage = originalFailure.ErrorMessage, ViaValidatorType = ValidatorType.Custom, ValidatorName = $"FluentValidation-{typeOfValidator.GetFriendlyName()}" }; targetFailure.Details.Add(error); } return(failureHolding.Select(x => x.Value)); }
public void Execute(DriverManager driver, TestStep step) { long order = step.Order; string wait = step.Wait != null ? step.Wait : ""; List <TestStep> steps = new List <TestStep>(); IWebElement ele; IWebElement chip; bool in_season = false; int loc; int months; int year; string title; string date; string path = ""; string data = ""; IJavaScriptExecutor js = (IJavaScriptExecutor)driver.GetDriver(); VerifyError err = new VerifyError(); Random random = new Random(); string[] regularSeason = { "November", "December", "January", "February", "March" }; string[] cbkGroups = { "TOP 25", "AAC", "ACC", "AMERICA EAST", "ATLANTIC 10", "ATLANTIC SUN", "BIG 12", "BIG EAST", "BIG SKY", "BIG SOUTH", "BIG TEN", "BIG WEST", "C-USA", "CAA", "DI-IND", "HORIZON", "IVY", "MAA", "MAC", "MEAC", "MVC", "MW", "NEC", "OVC", "PAC-12", "PATRIOT LEAGUE", "SEC", "SOUTHERN", "SOUTHLAND", "SUMMIT", "SUN BELT", "SWAC", "WAC", "WCC" }; if (step.Name.Equals("Select Regular Season CBK Date")) { DateTime now = DateTime.Now; date = now.ToString("MMMM"); // check if current month is in the regular season if (Array.Exists(regularSeason, element => element == date)) { loc = Array.IndexOf(regularSeason, date); if (loc == 0 || loc == regularSeason.Length - 1) { // current month is start or end of regular season. can only click one way on arrows. months = random.Next(1, regularSeason.Length); if (loc == 0) { for (int i = 0; i < months; i++) { steps.Add(new TestStep(order, "Click Arrow Right", "", "click", "xpath", "//div[@class='qs-arrow qs-right']", wait)); TestRunner.RunTestSteps(driver, null, steps); steps.Clear(); } } else { for (int i = 0; i < months; i++) { steps.Add(new TestStep(order, "Click Arrow Left", "", "click", "xpath", "//div[@class='qs-arrow qs-left']", wait)); TestRunner.RunTestSteps(driver, null, steps); steps.Clear(); } } } else { // current month is inside limits of regular season. can click both arrows. log.Info(loc); } } else { // month is not in regular season. // screen should default to last game of season months = random.Next(1, regularSeason.Length); for (int i = 0; i < months; i++) { steps.Add(new TestStep(order, "Click Arrow Left", "", "click", "xpath", "//div[@class='qs-arrow qs-left']", wait)); TestRunner.RunTestSteps(driver, null, steps); steps.Clear(); } } // store month steps.Add(new TestStep(order, "Capture Month", "MONTH", "capture", "xpath", "//span[contains(@class,'qs-month')]", wait)); TestRunner.RunTestSteps(driver, null, steps); steps.Clear(); // store date months = driver.FindElements("xpath", "//div[contains(@class,'qs-num')]").Count; months = random.Next(1, months + 1); steps.Add(new TestStep(order, "Capture Date", "DATE", "capture", "xpath", "(//div[contains(@class,'qs-num')])[" + months + "]", wait)); steps.Add(new TestStep(order, "Select Date", "", "click", "xpath", "(//div[contains(@class,'qs-num')])[" + months + "]", wait)); TestRunner.RunTestSteps(driver, null, steps); steps.Clear(); } else if (step.Name.Equals("Verify NCAA BK Date")) { if (String.IsNullOrEmpty(step.Data)) { if (DataManager.CaptureMap.ContainsKey("IN_SEASON")) { in_season = bool.Parse(DataManager.CaptureMap["IN_SEASON"]); if (in_season) { TimeSpan time = DateTime.UtcNow.TimeOfDay; int now = time.Hours; int et = now - 4; if (et >= 0 && et < 11) { log.Info("Current Eastern Time hour is " + et + ". Default to Yesterday."); step.Data = "YESTERDAY"; } else { log.Info("Current Eastern Time hour is " + et + ". Default to Today."); step.Data = "TODAY"; } } else { step.Data = "MON, APR 5"; } } else { log.Warn("No IN_SEASON variable available."); } } path = "//div[contains(@class,'scores-app-root')]/div[not(@style='display: none;')]//div[contains(@class,'week-selector')]//button/span[contains(@class,'title')]"; steps.Add(new TestStep(order, "Verify Displayed Day on NCAA BK", step.Data, "verify_value", "xpath", path, wait)); DataManager.CaptureMap["CURRENT"] = driver.FindElement("xpath", path).Text; TestRunner.RunTestSteps(driver, null, steps); steps.Clear(); } else if (step.Name.Equals("Verify CBK Groups")) { data = "//div[contains(@class,'scores-home-container')]//div[contains(@class,'active')]//ul"; steps.Add(new TestStep(order, "Open Conference Dropdown", "", "click", "xpath", "//a[@class='dropdown-menu-title']", wait)); steps.Add(new TestStep(order, "Verify Dropdown is Displayed", "", "verify_displayed", "xpath", data, wait)); TestRunner.RunTestSteps(driver, null, steps); steps.Clear(); data = data + "//li"; steps.Add(new TestStep(order, "Verify Number of Groups", "34", "verify_count", "xpath", data, wait)); TestRunner.RunTestSteps(driver, null, steps); steps.Clear(); var groups = driver.FindElements("xpath", data); for (int i = 0; i < groups.Count; i++) { if (cbkGroups[i].Equals(groups[i].GetAttribute("innerText"))) { log.Info("Success. " + cbkGroups[i] + " matches " + groups[i].GetAttribute("innerText")); } else { log.Error("***Verification FAILED. Expected data [" + cbkGroups[i] + "] does not match actual data [" + groups[i].GetAttribute("innerText") + "] ***"); err.CreateVerificationError(step, cbkGroups[i], groups[i].GetAttribute("innerText")); } } } else { throw new Exception("Test Step not found in script"); } }
public void Execute(DriverManager driver, TestStep step) { long order = step.Order; string wait = step.Wait != null ? step.Wait : ""; List <TestStep> steps = new List <TestStep>(); IWebElement ele; IWebElement chip; int total; int week; int months; int year; string title; string date; string data = ""; string teamSelector = ""; IJavaScriptExecutor js = (IJavaScriptExecutor)driver.GetDriver(); VerifyError err = new VerifyError(); Random random = new Random(); string[] playoffTeams = { "Kansas City Chiefs", "Tampa Bay Buccaneers" }; string[] preSeason = { "August" }; string[] preSeasonWeeks = { "HALL OF FAME GAME", "PRE WEEK 1", "PRE WEEK 2", "PRE WEEK 3", "PRE WEEK 4" }; string[] regSeason = { "September", "October", "November", "December", "January", "February" }; string[] regSeasonWeek = { "WEEK 1", "WEEK 2", "WEEK 3", "WEEK 4", "WEEK 5", "WEEK 6", "WEEK 7", "WEEK 8", "WEEK 9", "WEEK 10", "WEEK 11", "WEEK 12", "WEEK 13", "WEEK 14", "WEEK 15", "WEEK 16", "WEEK 17" }; string[] postSeason = { "January", "February" }; string[] postSeasonWeeks = { "WILD CARD", "DIVISIONAL CHAMPIONSHIP", "CONFERENCE CHAMPIONSHIP", "PRO BOWL", "SUPER BOWL" }; if (step.Name.Equals("Select Regular Season NFL Date")) { title = "//div[contains(@class,'scores') and not(@style='display: none;')][div[contains(@class,'dropdown')]]//ul[li[contains(.,'REGULAR SEASON')]]//li[not(contains(@class,'label'))]"; total = driver.FindElements("xpath", title).Count; week = random.Next(1, total + 1); steps.Add(new TestStep(order, "Capture Week", "WEEK", "capture", "xpath", "(" + title + ")[" + week + "]//div//div[1]", wait)); steps.Add(new TestStep(order, "Capture Dates", "WEEK_DATES", "capture", "xpath", "(" + title + ")[" + week + "]//div//div[2]", wait)); steps.Add(new TestStep(order, "Select Week", "", "click", "xpath", "(" + title + ")[" + week + "]", wait)); TestRunner.RunTestSteps(driver, null, steps); steps.Clear(); } else if (step.Name.Contains("Capture") && step.Name.Contains("Playoff Team")) { teamSelector = "//div[contains(@id,'App') and not(contains(@style,'none'))]//a[@class='entity-list-row-container']"; total = playoffTeams.Length; total = random.Next(1, total); steps.Add(new TestStep(order, "Capture Randomized Team", "RANDOM_TEAM", "capture", "xpath", teamSelector + "[div[contains(.,'" + playoffTeams[total - 1] + "')]]", wait)); // click as well if (step.Name.Contains("Click")) { steps.Add(new TestStep(order, "Click Randomized Team", "", "click", "xpath", teamSelector + "[div[contains(.,'" + playoffTeams[total - 1] + "')]]", wait)); } TestRunner.RunTestSteps(driver, null, steps); steps.Clear(); DataManager.CaptureMap["RANDOM_TEAM_UP"] = DataManager.CaptureMap["RANDOM_TEAM"].ToUpper(); } else if (step.Name.Equals("Verify NFL Week")) { if (String.IsNullOrEmpty(step.Data)) { DateTime today = DateTime.Now; // determine week of season by today's date and time if (today >= DateTime.Parse("09/01/2020") && today < DateTime.Parse("09/15/2020 11:00:00")) { step.Data = "WEEK 1"; } else if (today >= DateTime.Parse("09/15/2020 11:00:01") && today < DateTime.Parse("09/22/2020 11:00:00")) { step.Data = "WEEK 2"; } else if (today >= DateTime.Parse("09/22/2020 11:00:01") && today < DateTime.Parse("09/29/2020 11:00:00")) { step.Data = "WEEK 3"; } else if (today >= DateTime.Parse("09/29/2020 11:00:01") && today < DateTime.Parse("10/6/2020 11:00:00")) { step.Data = "WEEK 4"; } else if (today >= DateTime.Parse("10/6/2020 11:00:01") && today < DateTime.Parse("10/13/2020 11:00:00")) { step.Data = "WEEK 5"; } else if (today >= DateTime.Parse("10/13/2020 11:00:01") && today < DateTime.Parse("10/20/2020 11:00:00")) { step.Data = "WEEK 6"; } else if (today >= DateTime.Parse("10/20/2020 11:00:01") && today < DateTime.Parse("10/27/2020 11:00:00")) { step.Data = "WEEK 7"; } else if (today >= DateTime.Parse("10/27/2020 11:00:01") && today < DateTime.Parse("11/03/2020 11:00:00")) { step.Data = "WEEK 8"; } else if (today >= DateTime.Parse("11/03/2020 11:00:01") && today < DateTime.Parse("11/10/2020 11:00:00")) { step.Data = "WEEK 9"; } else if (today >= DateTime.Parse("11/10/2020 11:00:01") && today < DateTime.Parse("11/17/2020 11:00:00")) { step.Data = "WEEK 10"; } else if (today >= DateTime.Parse("11/17/2020 11:00:01") && today < DateTime.Parse("11/24/2020 11:00:00")) { step.Data = "WEEK 11"; } else if (today >= DateTime.Parse("11/24/2020 11:00:01") && today < DateTime.Parse("12/01/2020 11:00:00")) { step.Data = "WEEK 12"; } else if (today >= DateTime.Parse("12/01/2020 11:00:01") && today < DateTime.Parse("12/08/2020 11:00:00")) { step.Data = "WEEK 13"; } else if (today >= DateTime.Parse("12/08/2020 11:00:01") && today < DateTime.Parse("12/15/2020 11:00:00")) { step.Data = "WEEK 14"; } else if (today >= DateTime.Parse("12/15/2020 11:00:01") && today < DateTime.Parse("12/22/2020 11:00:00")) { step.Data = "WEEK 15"; } else if (today >= DateTime.Parse("12/22/2020 11:00:01") && today < DateTime.Parse("12/29/2020 11:00:00")) { step.Data = "WEEK 16"; } else if (today >= DateTime.Parse("12/29/2020 11:00:01") && today < DateTime.Parse("01/05/2021 11:00:00")) { step.Data = "WEEK 17"; } else if (today >= DateTime.Parse("01/05/2021 11:00:01") && today < DateTime.Parse("01/11/2021 11:00:00")) { step.Data = "WILD CARD"; } else if (today >= DateTime.Parse("01/11/2021 11:00:01") && today < DateTime.Parse("01/18/2021 11:00:00")) { step.Data = "DIVISIONAL CHAMPIONSHIP"; } else if (today >= DateTime.Parse("01/18/2021 11:00:01") && today < DateTime.Parse("01/25/2021 11:00:00")) { step.Data = "CONFERENCE CHAMPIONSHIP"; } else if (today >= DateTime.Parse("01/25/2021 11:00:01") && today < DateTime.Parse("02/01/2021 11:00:00")) { step.Data = "PRO BOWL"; } else if (today >= DateTime.Parse("01/25/2021 11:00:01") && today < DateTime.Parse("02/01/2021 11:00:00")) { step.Data = "PRO BOWL"; } else { step.Data = "SUPER BOWL"; } } steps.Add(new TestStep(order, "Verify Displayed Week on NFL", step.Data, "verify_value", "xpath", "//h2[contains(@class,'section-title fs-30 desktop-show') and not(@style='display: none;')]", wait)); DataManager.CaptureMap["CURRENT"] = driver.FindElement("xpath", "//div[contains(@class,'scores-app-root')]/div[not(@style='display: none;')]//div[contains(@class,'week-selector')]//button/span[contains(@class,'title')]").Text; TestRunner.RunTestSteps(driver, null, steps); steps.Clear(); } else if (step.Name.Equals("Store Team's Conference and Division")) { switch (step.Data) { case "Baltimore Ravens": case "Cincinnati Bengals": case "Cleveland Browns": case "Pittsburgh Steelers": DataManager.CaptureMap["TEAM_CONF"] = "AFC"; DataManager.CaptureMap["TEAM_DIV"] = "AFC NORTH"; break; case "Buffalo Bills": case "Miami Dolphins": case "New England Patriots": case "New York Jets": DataManager.CaptureMap["TEAM_CONF"] = "AFC"; DataManager.CaptureMap["TEAM_DIV"] = "AFC EAST"; break; case "Houston Texas": case "Indianapolis Colts": case "Jacksonville Jaguars": case "Tennessee Titans": DataManager.CaptureMap["TEAM_CONF"] = "AFC"; DataManager.CaptureMap["TEAM_DIV"] = "AFC SOUTH"; break; case "Denver Broncos": case "Kansas City Chiefs": case "Los Angeles Chargers": case "Las Vegas Raiders": DataManager.CaptureMap["TEAM_CONF"] = "AFC"; DataManager.CaptureMap["TEAM_DIV"] = "AFC WEST"; break; case "Chicago Bears": case "Detroit Lions": case "Green Bay Packers": case "Minnesota Vikings": DataManager.CaptureMap["TEAM_CONF"] = "NFC"; DataManager.CaptureMap["TEAM_DIV"] = "NFC NORTH"; break; case "Dallas Cowboys": case "New York Giants": case "Philadelphia Eagles": case "Washington Football Team": DataManager.CaptureMap["TEAM_CONF"] = "NFC"; DataManager.CaptureMap["TEAM_DIV"] = "NFC EAST"; break; case "Atlanta Falcons": case "Carolina Panthers": case "New Orleans Saints": case "Tampa Bay Buccaneers": DataManager.CaptureMap["TEAM_CONF"] = "NFC"; DataManager.CaptureMap["TEAM_DIV"] = "NFC SOUTH"; break; default: DataManager.CaptureMap["TEAM_CONF"] = "NFC"; DataManager.CaptureMap["TEAM_DIV"] = "NFC WEST"; break; } } else { throw new Exception("Test Step not found in script"); } }
public void Execute(DriverManager driver, TestStep step) { long order = step.Order; string wait = step.Wait != null ? step.Wait : ""; int eleCount = 0; int total; int size = 0; string date = ""; string cat = ""; string search = ""; List <string> teams = new List <string>(); List <TestStep> steps = new List <TestStep>(); VerifyError err = new VerifyError(); TextInfo ti = new CultureInfo("en-US", false).TextInfo; if (step.Name.Equals("Verify Team Search by Sport")) { switch (step.Data) { case "NFL": string[] nfl = { "NFL", "ARIZONA CARDINALS", "ATLANTA FALCONS", "BALTIMORE RAVENS", "BUFFALO BILLS", "CAROLINA PANTHERS", "CHICAGO BEARS", "CINCINNATI BENGALS", "CLEVELAND BROWNS", "DALLAS COWBOYS", "DENVER BRONCOS", "DETROIT LIONS", "GREEN BAY PACKERS", "HOUSTON TEXANS", "INDIANAPOLIS COLTS", "JACKSONVILLE JAGUARS", "KANSAS CITY CHIEFS", "LAS VEGAS RAIDERS", "LOS ANGELES CHARGERS", "LOS ANGELES RAMS", "MIAMI DOLPHINS", "MINNESOTA VIKINGS", "NEW ENGLAND PATRIOTS", "NEW ORLEANS SAINTS", "NEW YORK GIANTS", "NEW YORK JETS", "PHILADELPHIA EAGLES", "PITTSBURGH STEELERS", "SAN FRANCISCO 49ERS", "SEATTLE SEAHAWKS", "TAMPA BAY BUCCANEERS", "TENNESSEE TITANS", "WASHINGTON FOOTBALL TEAM" }; teams.AddRange(nfl); break; case "NBA": string[] nba = { "NBA", "ATLANTA HAWKS", "BOSTON CELTICS", "BROOKLYN NETS", "CHARLOTTE HORNETS", "CHICAGO BULLS", "CLEVELAND CAVALIERS", "DALLAS MAVERICKS", "DENVER NUGGETS", "DETROIT PISTONS", "GOLDEN STATE WARRIORS", "HOUSTON ROCKETS", "INDIANA PACERS", "LA CLIPPERS", "LOS ANGELES LAKERS", "MEMPHIS GRIZZLIES", "MIAMI HEAT", "MILWAUKEE BUCKS", "MINNESOTA TIMBERWOLVES", "NEW ORLEANS PELICANS", "NEW YORK KNICKS", "OKLAHOMA CITY THUNDER", "ORLANDO MAGIC", "PHILADELPHIA 76ERS", "PHOENIX SUNS", "PORTLAND TRAIL BLAZERS", "SACRAMENTO KINGS", "SAN ANTONIO SPURS", "TORONTO RAPTORS", "UTAH JAZZ", "WASHINGTON WIZARDS" }; teams.AddRange(nba); break; case "NHL": string[] nhl = { "NHL", "ANAHEIM DUCKS", "ARIZONA COYOTES", "BOSTON BRUINS", "BUFFALO SABRES", "CALGARY FLAMES", "CAROLINA HURRICANES", "CHICAGO BLACKHAWKS", "COLORADO AVALANCHE", "DALLAS STARS", "DETROIT RED WINGS", "EDMONTON OILERS", "FLORIDA PANTHERS", "LOS ANGELES KINGS", "MINNESOTA WILD", "MONTREAL CANADIENS", "NASHVILLE PREDATORS", "NEW JERSEY DEVILS", "NEW YORK ISLANDERS", "NEW YORK RANGERS", "OTTAWA SENATORS", "PHILADELPHIA FLYERS", "PITTSBURGH PENGUINS", "SAN JOSE SHARKS", "ST. LOUIS BLUES", "TAMPA BAY LIGHTNING", "TORONTO MAPLE LEAFS", "VANCOUVER CANUCKS", "VEGAS GOLDEN KNIGHTS", "WASHINGTON CAPITALS", "WINNIPEG JETS" }; teams.AddRange(nhl); break; case "MLB": string[] mlb = { "MLB", "ARIZONA DIAMONDBACKS", "ATLANTA BRAVES", "BALTIMORE ORIOLES", "BOSTON RED SOX", "CHICAGO CUBS", "CHICAGO WHITE SOX", "CINCINNATI REDS", "CLEVELAND INDIANS", "COLORADO ROCKIES", "DETROIT TIGERS", "HOUSTON ASTROS", "KANSAS CITY ROYALS", "LOS ANGELES ANGELS", "LOS ANGELES DODGERS", "MIAMI MARLINS", "MILWAUKEE BREWERS", "MINNESOTA TWINS", "NEW YORK METS", "NEW YORK YANKEES", "OAKLAND ATHLETICS", "PHILADELPHIA PHILLIES", "PITTSBURGH PIRATES", "SAN DIEGO PADRES", "SAN FRANCISCO GIANTS", "SEATTLE MARINERS", "ST. LOUIS CARDINALS", "TAMPA BAY RAYS", "TEXAS RANGERS", "TORONTO BLUE JAYS", "WASHINGTON NATIONALS" }; teams.AddRange(mlb); break; default: break; } foreach (string team in teams) { // temporary fix search = "//input[@type='search']"; steps.Add(new TestStep(order, "Click Search", "", "click", "xpath", search, wait)); if (team.Equals("MLB") || team.Equals("NBA") || team.Equals("NFL") || team.Equals("NHL") || team.Equals("SAN FRANCISCO 49ERS") || team.Equals("PHILADELPHIA 76ERS") || team.Equals("LA CLIPPERS")) { switch (team) { case "MLB": cat = "Major League Baseball"; break; case "NBA": cat = "National Basketball Association"; break; case "NFL": cat = "National Football League"; break; case "NHL": cat = "National Hockey League"; break; case "SAN FRANCISCO 49ERS": cat = "San Francisco 49ers"; break; case "PHILADELPHIA 76ERS": cat = "Philadelphia 76ers"; break; case "LA CLIPPERS": cat = "LA Clippers"; break; default: cat = ""; break; } steps.Add(new TestStep(order, "Enter Search", cat, "input_text", "xpath", search, wait)); steps.Add(new TestStep(order, "Verify Search Term", cat, "verify_value", "xpath", "(//div[contains(@class,'explore-search')]//div[contains(@class,'row-title')])[1]", wait)); } else { steps.Add(new TestStep(order, "Enter Search", ti.ToTitleCase(team.ToLower()), "input_text", "xpath", search, wait)); steps.Add(new TestStep(order, "Verify Search Term", ti.ToTitleCase(team.ToLower()), "verify_value", "xpath", "(//div[contains(@class,'explore-search')]//div[contains(@class,'row-title')])[1]", wait)); } TestRunner.RunTestSteps(driver, null, steps); steps.Clear(); } } else { log.Warn("Test Step not found in script..."); } }
public void Execute(DriverManager driver, TestStep step) { long order = step.Order; string wait = step.Wait != null ? step.Wait : ""; List <TestStep> steps = new List <TestStep>(); IWebElement ele; IWebElement chip; bool in_season = false; string path = ""; int loc; int months; int year; string title; string date; string data = ""; IJavaScriptExecutor js = (IJavaScriptExecutor)driver.GetDriver(); VerifyError err = new VerifyError(); Random random = new Random(); if (step.Name.Equals("Select Regular Season NBA Date")) { string[] regularSeason = new string[] { "September", "October", "November", "December", "January", "February", "March", "April" }; DateTime now = DateTime.Now; date = now.ToString("MMMM"); // check if current month is in the regular season if (Array.Exists(regularSeason, element => element == date)) { loc = Array.IndexOf(regularSeason, date); if (loc == 0 || loc == regularSeason.Length - 1) { // current month is start or end of regular season. can only click one way on arrows. months = random.Next(2, regularSeason.Length); if (loc == 0) { for (int i = 0; i < months; i++) { steps.Add(new TestStep(order, "Click Arrow Right", "", "click", "xpath", "//div[@class='qs-arrow qs-right']", wait)); TestRunner.RunTestSteps(driver, null, steps); steps.Clear(); } } else { for (int i = 0; i < months; i++) { steps.Add(new TestStep(order, "Click Arrow Left", "", "click", "xpath", "//div[@class='qs-arrow qs-left']", wait)); TestRunner.RunTestSteps(driver, null, steps); steps.Clear(); } } } else { // current month is inside limits of regular season. can click both arrows. log.Info(loc); } steps.Add(new TestStep(order, "Capture Month", "MONTH", "capture", "xpath", "//span[contains(@class,'qs-month')]", wait)); TestRunner.RunTestSteps(driver, null, steps); steps.Clear(); } else { // month is not in regular season. // navigate to most recent month of season. assume end of last season. //div[@class='qs-arrow qs-left'] // check if current month is in regular season } months = driver.FindElements("xpath", "//div[contains(@class,'qs-num')]").Count; months = random.Next(1, months + 1); steps.Add(new TestStep(order, "Capture Date", "DATE", "capture", "xpath", "(//div[contains(@class,'qs-num')])[" + months + "]", wait)); steps.Add(new TestStep(order, "Select Date", "", "click", "xpath", "(//div[contains(@class,'qs-num')])[" + months + "]", wait)); TestRunner.RunTestSteps(driver, null, steps); steps.Clear(); } else if (step.Name.Equals("Verify NBA Date")) { if (String.IsNullOrEmpty(step.Data)) { if (DataManager.CaptureMap.ContainsKey("IN_SEASON")) { in_season = bool.Parse(DataManager.CaptureMap["IN_SEASON"]); if (in_season) { TimeSpan time = DateTime.UtcNow.TimeOfDay; int now = time.Hours; int et = now - 4; if (et >= 0 && et < 11) { log.Info("Current Eastern Time hour is " + et + ". Default to Yesterday."); step.Data = "YESTERDAY"; } else { log.Info("Current Eastern Time hour is " + et + ". Default to Today."); step.Data = "TODAY"; } } else { step.Data = "WED, OCT 14"; } } else { log.Warn("No IN_SEASON variable available."); } } path = "//div[contains(@class,'scores-app-root')]/div[not(@style='display: none;')]//div[contains(@class,'week-selector')]//button/span[contains(@class,'title')]"; steps.Add(new TestStep(order, "Verify Displayed Day on NBA", step.Data, "verify_value", "xpath", path, wait)); DataManager.CaptureMap["CURRENT"] = driver.FindElement("xpath", path).Text; TestRunner.RunTestSteps(driver, null, steps); steps.Clear(); } else { throw new Exception("Test Step not found in script"); } }
public void Execute(DriverManager driver, TestStep step) { long order = step.Order; string wait = step.Wait != null ? step.Wait : ""; List <TestStep> steps = new List <TestStep>(); IJavaScriptExecutor js = (IJavaScriptExecutor)driver.GetDriver(); VerifyError err = new VerifyError(); Random random = new Random(); bool in_season = false; IWebElement ele; string games = ""; int scrolls = 20; string status = ""; string date = ""; int loc; int rand; int months; if (step.Name.Equals("Verify Soccer Date")) { if (String.IsNullOrEmpty(step.Data)) { if (DataManager.CaptureMap.ContainsKey("IN_SEASON")) { in_season = bool.Parse(DataManager.CaptureMap["IN_SEASON"]); if (in_season) { TimeSpan time = DateTime.UtcNow.TimeOfDay; int now = time.Hours; int et = now - 4; if (et >= 0 && et < 11) { log.Info("Current Eastern Time hour is " + et + ". Default to Yesterday."); step.Data = "YESTERDAY"; DataManager.CaptureMap["IN_SEASON"] = "YESTERDAY"; } else { log.Info("Current Eastern Time hour is " + et + ". Default to Today."); step.Data = "TODAY"; DataManager.CaptureMap["CURRENT"] = "TODAY"; } } else { step.Data = "WED, NOV 18"; } } else { log.Warn("No IN_SEASON variable available."); } } steps.Add(new TestStep(order, "Verify Displayed Day on Soccer", step.Data, "verify_value", "xpath", "//div[contains(@class,'scores-app-root')]/div[not(@style='display: none;')]//div[contains(@class,'week-selector')]//button/span[contains(@class,'title')]", wait)); TestRunner.RunTestSteps(driver, null, steps); steps.Clear(); } else if (step.Name.Equals("Verify Soccer Event")) { if (DataManager.CaptureMap.ContainsKey("IN_SEASON")) { DataManager.CaptureMap["GAME"] = step.Data; ele = driver.FindElement("xpath", "(//a[contains(@class,'score-chip')])[" + step.Data + "]"); games = ele.GetAttribute("className"); games = games.Substring(games.IndexOf(" ") + 1); log.Info("Game State: " + games); if (games.Equals("pregame")) { step.Data = "TeamSport_FutureEvent"; DataManager.CaptureMap["EVENT_STATUS"] = "FUTURE"; } else if (games.Equals("live")) { step.Data = "TeamSport_LiveEvent"; DataManager.CaptureMap["EVENT_STATUS"] = "LIVE"; } else { status = driver.FindElement("xpath", "(//a[contains(@class,'score-chip')])[" + step.Data + "]//div[contains(@class,'status-text')]").Text; log.Info("Event status: " + status); if (status.Equals("POSTPONED") || status.Equals("CANCELED")) { step.Data = "TeamSport_PostponedEvent"; DataManager.CaptureMap["EVENT_STATUS"] = "POSTPONED"; } else { step.Data = "TeamSport_PastEvent"; DataManager.CaptureMap["EVENT_STATUS"] = "FINAL"; } } } else { log.Warn("No IN_SEASON variable available or data is populated. Using data."); } steps.Add(new TestStep(order, "Run Event Template", step.Data, "run_template", "xpath", "", wait)); TestRunner.RunTestSteps(driver, null, steps); steps.Clear(); } else { throw new Exception("Test Step not found in script"); } }
public void Execute(DriverManager driver, TestStep step) { long order = step.Order; string wait = step.Wait != null ? step.Wait : ""; List <TestStep> steps = new List <TestStep>(); IWebElement ele; string data = ""; string xpath = ""; int count = 0; //List of necessary data List <string> activeTrainingJobConfigIDArray = new List <string>(); List <string> inactiveTrainingJobConfigIDArray = new List <string>(); List <string> activeTrainingJobConfigTypeIDArray = new List <string>(); List <string> inactiveTrainingJobConfigTypeIDArray = new List <string>(); List <string> activeJobSettingsArray = new List <string>(); List <string> inactiveJobSettingsArray = new List <string>(); List <string> activeModelConfigIDArray = new List <string>(); List <string> inactiveModelConfigIDArray = new List <string>(); List <string> activeNameArray = new List <string>(); List <string> inactiveNameArray = new List <string>(); //Fetching json file JObject json = new JObject(); using (var webClient = new System.Net.WebClient()) { var jsonString = webClient.DownloadString("http://recspublicdev-1454793804.us-east-2.elb.amazonaws.com/v2/training/job/configuration"); json = JObject.Parse(jsonString); } //Getting data foreach (JToken x in json["result"]) { if (x["ConfigurationStatus"].ToString().Equals("active")) { //Active TrainingJobConfigurationID if (x["TrainingJobConfigurationID"] != null) { activeTrainingJobConfigIDArray.Add(x["TrainingJobConfigurationID"].ToString()); } else { activeTrainingJobConfigIDArray.Add(""); } //Active Name if (x["Name"] != null) { activeNameArray.Add(x["Name"].ToString()); } else { activeNameArray.Add(""); } //Active TrainingJobConfigurationTypeID if (x["TrainingJobConfigurationTypeID"] != null) { activeTrainingJobConfigTypeIDArray.Add(x["TrainingJobConfigurationTypeID"].ToString()); } else { activeTrainingJobConfigTypeIDArray.Add(""); } //Active JobSettings if (x["JobSettings"] != null) { activeJobSettingsArray.Add(x["JobSettings"].ToString()); } else { activeJobSettingsArray.Add(""); } //Active ModelConfigurationID if (x["ModelConfigurationID"] != null) { activeModelConfigIDArray.Add(x["ModelConfigurationID"].ToString()); } else { activeModelConfigIDArray.Add(""); } } } Dictionary <string, string[]> dataDictionary = new Dictionary <string, string[]>(); dataDictionary.Add("activeTrainingJobConfigIDArray", activeTrainingJobConfigIDArray.ToArray()); dataDictionary.Add("activeNameArray", activeNameArray.ToArray()); dataDictionary.Add("TrainingJobConfigurationTypeID", activeTrainingJobConfigTypeIDArray.ToArray()); dataDictionary.Add("activeJobSettingsArray", activeJobSettingsArray.ToArray()); dataDictionary.Add("activeModelConfigIDArray", activeModelConfigIDArray.ToArray()); VerifyError err = new VerifyError(); ReadOnlyCollection <IWebElement> elements; if (step.Name.Equals("Check Training Job ID")) { string[] id = dataDictionary["activeTrainingJobConfigIDArray"]; elements = driver.FindElements("xpath", "/html/body/div/main/div/div[1]/table/tbody/tr/td[1]"); if (elements.Count > 0) { for (int i = 0; i < elements.Count; i++) { if (elements.ElementAt(i).GetAttribute("innerText").Equals(id[i])) { log.Info("Match! " + "Expected: " + id[i] + " Actual: " + elements.ElementAt(i).GetAttribute("innerText")); } else { err.CreateVerificationError(step, "Expected ID: " + id[i], "Actual ID: " + elements.ElementAt(i).GetAttribute("innerText")); } } } else { log.Error("Can't find ID values"); } } else if (step.Name.Equals("Check Training Name")) { string[] id = dataDictionary["activeNameArray"]; elements = driver.FindElements("xpath", "/html/body/div/main/div/div[1]/table/tbody/tr/td[3]"); if (elements.Count > 0) { for (int i = 0; i < elements.Count; i++) { if (elements.ElementAt(i).GetAttribute("innerText").Equals(id[i])) { log.Info("Match! " + "Expected: " + id[i] + " Actual: " + elements.ElementAt(i).GetAttribute("innerText")); } else { err.CreateVerificationError(step, "Expected Training Name: " + id[i], "Actual Training Name: " + elements.ElementAt(i).GetAttribute("innerText")); } } } else { log.Error("Can't Find Traning Name Value(s)"); } } }
public void Execute(DriverManager driver, TestStep step) { long order = step.Order; string wait = step.Wait != null ? step.Wait : ""; List <TestStep> steps = new List <TestStep>(); IJavaScriptExecutor js = (IJavaScriptExecutor)driver.GetDriver(); VerifyError err = new VerifyError(); ReadOnlyCollection <IWebElement> elements; if (step.Name.Equals("Verify Footer Links")) { string[] dataSet = new string[] { "Help", "Press", "Advertise with Us", "Jobs", "FOX Cincy", "RSS", "Sitemap" }; elements = driver.FindElements("xpath", "//div[@class='footer-links-1']//a"); if (dataSet.Length != elements.Count) { err.CreateVerificationError(step, dataSet.Length.ToString(), elements.Count.ToString()); } else { for (int i = 0; i < elements.Count; i++) { if (dataSet[i].Equals(elements[i].GetAttribute("innerText").Trim())) { log.Info("Verification Passed. Expected [" + dataSet[i] + "] matches Actual [" + elements[i].GetAttribute("innerText").Trim() + "]"); } else { err.CreateVerificationError(step, dataSet[i], elements[i].GetAttribute("innerText").Trim()); } } } } else if (step.Name.Equals("Verify Footer Links 2")) { string[] dataSet = { "FS1", "FOX", "FOX News", "Fox Corporation", "FOX Sports Supports", "FOX Deportes", "Regional Sports Networks" }; elements = driver.FindElements("xpath", "//div[@class='footer-links-2']//a"); if (dataSet.Length != elements.Count) { err.CreateVerificationError(step, dataSet.Length.ToString(), elements.Count.ToString()); } else { for (int i = 0; i < elements.Count; i++) { if (dataSet[i].Equals(elements[i].GetAttribute("innerText").Trim())) { log.Info("Verification Passed. Expected [" + dataSet[i] + "] matches Actual [" + elements[i].GetAttribute("innerText").Trim() + "]"); } else { err.CreateVerificationError(step, dataSet[i], elements[i].GetAttribute("innerText").Trim()); } } } } else { throw new Exception("Test Step not found in script"); } }
public void Execute(DriverManager driver, TestStep step) { VerifyError err = new VerifyError(); Random random = new Random(); int sports; string favorites = ""; long order = step.Order; string wait = step.Wait != null ? step.Wait : ""; List <TestStep> steps = new List <TestStep>(); bool show = false; if (step.Name.Contains("Randomize Favorite")) { string fullName = ""; string sport = ""; favorites = "//div[contains(@id,'App') and not(contains(@style,'none'))]//a[contains(@class,'entity-list-row-container')]"; // Flip to Players pane if necessary. Otherwise, stay on Sports pane. if (step.Name.Contains("Player")) { steps.Add(new TestStep(order, "Click Players Pane", "", "click", "xpath", "//nav[contains(@class,'explore-subnav')]//div//a[contains(.,'PLAYERS')]", wait)); TestRunner.RunTestSteps(driver, null, steps); steps.Clear(); } // Flip to Shows pane if necessary. Otherwise, stay on Sports pane. if (step.Name.Contains("Show")) { show = true; steps.Add(new TestStep(order, "Click Shows Pane", "", "click", "xpath", "//nav[contains(@class,'explore-subnav')]//div//a[contains(.,'SHOWS')]", wait)); TestRunner.RunTestSteps(driver, null, steps); steps.Clear(); } // Allows for favoriting by NCAA entity or Professional entity if (step.Name.Contains("NCAA")) { sports = driver.FindElements("xpath", favorites + "[div[div[(contains(.,'NCAA'))]]]").Count; sports = random.Next(1, sports + 1); steps.Add(new TestStep(order, "Click Randomized NCAA Sport", "", "click", "xpath", "(" + favorites + "[div[div[(contains(.,'NCAA'))]]])[" + sports + "]", wait)); TestRunner.RunTestSteps(driver, null, steps); steps.Clear(); } else if (show) { sports = driver.FindElements("xpath", favorites).Count; sports = random.Next(1, sports + 1); steps.Add(new TestStep(order, "Capture Show Name", "SHOW", "capture", "xpath", "(" + favorites + ")[" + sports + "]//div[contains(@class,'-title')]", wait)); steps.Add(new TestStep(order, "Select Show", "", "click", "xpath", "(" + favorites + ")[" + sports + "]", wait)); TestRunner.RunTestSteps(driver, null, steps); steps.Clear(); fullName = DataManager.CaptureMap["SHOW"]; } else { sports = driver.FindElements("xpath", favorites + "[div[div[(contains(.,'NFL') or contains(.,'MLB') or contains(.,'NBA') or contains(.,'NHL'))]]]").Count; sports = random.Next(1, sports + 1); steps.Add(new TestStep(order, "Clicking Randomized Pro Sport", "", "click", "xpath", "(//a[contains(@class,'entity-list-row-container')][div[div[(contains(.,'NFL') or contains(.,'MLB') or contains(.,'NBA') or contains(.,'NHL'))]]])[" + sports + "]", wait)); TestRunner.RunTestSteps(driver, null, steps); steps.Clear(); } // Capture League for Teams if (!step.Name.Contains("Player") && show == false) { steps.Add(new TestStep(order, "Capture League Entity", "LEAGUE", "capture", "xpath", "//a[contains(@class,'explore-league-header')]", wait)); TestRunner.RunTestSteps(driver, null, steps); steps.Clear(); } // Allows for favoriting Leagues if (step.Name.Contains("League") || step.Name.Contains("NCAA")) { // set proper league names if (DataManager.CaptureMap.ContainsKey("LEAGUE")) { log.Info("LEAGUE key found, setting full name"); switch (DataManager.CaptureMap["LEAGUE"]) { case "NFL": fullName = "National Football League"; break; case "MLB": fullName = "Major League Baseball"; break; case "NBA": fullName = "National Basketball Association"; break; case "NHL": fullName = "National Hockey League"; break; case "NCAA BK": fullName = "NCAA Basketball"; sport = " Basketball"; break; case "NCAA FB": fullName = "NCAA Football"; sport = " Football"; break; } } if (step.Name.Contains("NCAA") && !step.Name.Contains("League")) { sports = driver.FindElements("xpath", favorites).Count; sports = random.Next(2, sports); steps.Add(new TestStep(order, "Capture Conference", "CONF", "capture", "xpath", "(" + favorites + ")[" + sports + "]", wait)); steps.Add(new TestStep(order, "Click into Conference", "", "click", "xpath", "(" + favorites + ")[" + sports + "]", wait)); TestRunner.RunTestSteps(driver, null, steps); steps.Clear(); fullName = DataManager.CaptureMap["CONF"] + sport; } if (!(step.Name.Contains("Player") || step.Name.Contains("Team"))) { steps.Add(new TestStep(order, "Favorite League/Conference", "", "click", "xpath", "//div[contains(@id,'App') and not(contains(@style,'none'))]//a[contains(@class,'explore-league-header')]", wait)); TestRunner.RunTestSteps(driver, null, steps); steps.Clear(); } } // Select a Team for Team/Player Favorites if (step.Name.Contains("Team") || step.Name.Contains("Player")) { sports = driver.FindElements("xpath", favorites).Count; sports = random.Next(2, sports + 1); steps.Add(new TestStep(order, "Capture Team Name", "TEAM", "capture", "xpath", "(" + favorites + ")[" + sports + "]", wait)); steps.Add(new TestStep(order, "Click into Team", "", "click", "xpath", "(" + favorites + ")[" + sports + "]", wait)); TestRunner.RunTestSteps(driver, null, steps); steps.Clear(); fullName = DataManager.CaptureMap["TEAM"]; } // Allow for Favoriting Players if (step.Name.Contains("Player")) { sports = driver.FindElements("xpath", favorites).Count; sports = random.Next(1, sports + 1); steps.Add(new TestStep(order, "Capture Player Name", "PLAYER", "capture", "xpath", "(" + favorites + ")[" + sports + "]", wait)); steps.Add(new TestStep(order, "Select Player", "", "click", "xpath", "(" + favorites + ")[" + sports + "]", wait)); TestRunner.RunTestSteps(driver, null, steps); steps.Clear(); fullName = DataManager.CaptureMap["PLAYER"]; } // Verify the Toast Message, Close it, and clean up variables steps.Add(new TestStep(order, "Verify Toast", fullName + " - Added to your favorites.", "verify_value", "xpath", "//div[contains(@class,'toast-msg')]/div[contains(@class,'toast-msg')]", wait)); steps.Add(new TestStep(order, "Close Toast", "", "click", "xpath", "//div[contains(@class,'toast')]//div[contains(@class,'close-icon')]", wait)); TestRunner.RunTestSteps(driver, null, steps); DataManager.CaptureMap.Remove("LEAGUE"); DataManager.CaptureMap.Remove("CONF"); DataManager.CaptureMap.Remove("TEAM"); DataManager.CaptureMap.Remove("PLAYER"); DataManager.CaptureMap.Remove("SHOW"); steps.Clear(); } }
public void Execute(DriverManager driver, TestStep step) { long order = step.Order; string wait = step.Wait != null ? step.Wait : ""; List <TestStep> steps = new List <TestStep>(); IWebElement ele; string data = ""; IJavaScriptExecutor js = (IJavaScriptExecutor)driver.GetDriver(); VerifyError err = new VerifyError(); int number = 1; ReadOnlyCollection <IWebElement> elements; int count = 0; int bars = 0; if (step.Name.Equals("Verify Event Odds Details by Number")) { bool numeric = int.TryParse(step.Data, out number); steps.Add(new TestStep(order, "Verify Number of Header Items", "3", "verify_count", "xpath", "(//div[contains(@class,'event')]//a)[" + number + "]//div[contains(@class,'event-card-header')]//div[contains(@class,'flex-col')]", wait)); TestRunner.RunTestSteps(driver, null, steps); steps.Clear(); for (int i = 1; i <= 3; i++) { switch (i) { case 1: if (DataManager.CaptureMap["SPORT"].Equals("MLB")) { data = "RUN LINE"; } else { data = "SPREAD"; } break; case 2: data = "TEAM TO WIN"; break; default: data = "TOTAL"; break; } if (numeric) { number = Int32.Parse(step.Data); steps.Add(new TestStep(order, "Verify First Slide Odds Header", data, "verify_value", "xpath", "(//div[contains(@class,'event-container')])[" + number + "]//div[contains(@class,'feed-component')]//li[" + i + "]//div[contains(@class,'chart-container-header')]//div[contains(@class,'text fs')]", wait)); steps.Add(new TestStep(order, "Verify Sub Header Text Exists", "", "verify_displayed", "xpath", "(//div[contains(@class,'event-container')])[" + number + "]//div[contains(@class,'feed-component')]//li[" + i + "]//div[contains(@class,'chart-container-header')]//div[contains(@class,'sub-header')]", wait)); steps.Add(new TestStep(order, "Verify Odds Numbers Exist", "", "verify_displayed", "xpath", "((//div[contains(@class,'event-container')])[" + number + "]//div[contains(@class,'feed-component')]//li[" + i + "]//div[contains(@class,'chart-container-header')]//div[contains(@class,'number')])[1]", wait)); steps.Add(new TestStep(order, "Verify Odds Numbers Exist", "", "verify_displayed", "xpath", "((//div[contains(@class,'event-container')])[" + number + "]//div[contains(@class,'feed-component')]//li[" + i + "]//div[contains(@class,'chart-container-header')]//div[contains(@class,'number')])[2]", wait)); TestRunner.RunTestSteps(driver, null, steps); steps.Clear(); } if (i != 3) { steps.Add(new TestStep(order, "Click Arrow Right", "", "click", "xpath", "(//button[contains(@class,'next')])[" + number + "]", wait)); TestRunner.RunTestSteps(driver, null, steps); steps.Clear(); } } } else if (step.Name.Equals("Click Prop Header By Name")) { DataManager.CaptureMap["PROP"] = step.Data; //steps.Add(new TestStep(order, "Click " + step.Data, "", "click", "xpath", "//div[contains(@class,'prop-bets-name') and contains(.,'"+ step.Data.ToUpper()+"')]", wait)); TestRunner.RunTestSteps(driver, null, steps); steps.Clear(); ele = driver.FindElement("xpath", "//div[contains(@class,'prop-bets-component')][div[contains(.,'" + DataManager.CaptureMap["PROP"].ToUpper() + "')]]"); js.ExecuteScript("arguments[0].scrollIntoView(true);", ele); } else if (step.Name.Equals("Verify Number of Current Prop Displayed")) { steps.Add(new TestStep(order, "Verify Number of " + DataManager.CaptureMap["PROP"], step.Data, "verify_count", "xpath", "//div[contains(@class,'prop-bets-component')][div[contains(.,'" + DataManager.CaptureMap["PROP"].ToUpper() + "')]]//tbody/tr", wait)); TestRunner.RunTestSteps(driver, null, steps); steps.Clear(); } else if (step.Name.Equals("Click See All Futures for Current Prop")) { steps.Add(new TestStep(order, "Click See All " + DataManager.CaptureMap["PROP"], "", "click", "xpath", "//div[contains(@class,'prop-bets-component')][div[contains(.,'" + DataManager.CaptureMap["PROP"].ToUpper() + "')]]//a[contains(.,'SEE ALL')]", wait)); TestRunner.RunTestSteps(driver, null, steps); steps.Clear(); } else if (step.Name.Equals("Verify Team Text Exists for Current Prop")) { elements = driver.FindElements("xpath", "//div[contains(@class,'prop-bets-component')][div[contains(.,'" + DataManager.CaptureMap["PROP"].ToUpper() + "')]]//div[contains(@class,'flex')]"); foreach (IWebElement e in elements) { if (!String.IsNullOrEmpty(e.GetAttribute("innerText"))) { log.Info("Verification PASSED. Element text is " + e.GetAttribute("innerText") + "."); } else { log.Error("***Verification FAILED. Element returned no text. ***"); err.CreateVerificationError(step, "Team Text Expected", e.GetAttribute("innerText")); driver.TakeScreenshot(DataManager.CaptureMap["TEST_ID"] + "_verification_failure_" + DataManager.VerifyErrors.Count); } } } else if (step.Name.Equals("Verify Odds Text Exists for Current Prop")) { elements = driver.FindElements("xpath", "//div[contains(@class,'prop-bets-component')][div[contains(.,'" + DataManager.CaptureMap["PROP"].ToUpper() + "')]]//span[contains(@class,'ff')]"); foreach (IWebElement e in elements) { if (!String.IsNullOrEmpty(e.GetAttribute("innerText"))) { log.Info("Verification PASSED. Element text is " + e.GetAttribute("innerText") + "."); } else { log.Error("***Verification FAILED. Element returned no text. ***"); err.CreateVerificationError(step, "Team Text Expected", e.GetAttribute("innerText")); driver.TakeScreenshot(DataManager.CaptureMap["TEST_ID"] + "_verification_failure_" + DataManager.VerifyErrors.Count); } } } else if (step.Name.Equals("Verify Number of Event Props")) { count = driver.FindElements("xpath", "//div[contains(@class,'prop-bets-component')]/div[contains(@class,'prop-bets-event-title') or contains(.,'PROPS')]").Count; ele = driver.FindElement("xpath", "//div[contains(@class,'odds-container')]/div[contains(@class,'btm')][2]"); js.ExecuteScript("arguments[0].scrollIntoView(true);", ele); if (count >= 1 && count <= 5) { log.Info("Verication PASSED. " + count + " is between 1 and 5."); } else { log.Error("***Verification FAILED. Props expected to be between 1 and 5. Actual total is " + count + ". ***"); err.CreateVerificationError(step, "Between 1 and 5", count.ToString()); driver.TakeScreenshot(DataManager.CaptureMap["TEST_ID"] + "_verification_failure_" + DataManager.VerifyErrors.Count); } } else { throw new Exception("Test Step not found in script"); } }
public void Execute(DriverManager driver, TestStep step) { long order = step.Order; string wait = step.Wait != null ? step.Wait : ""; List <TestStep> steps = new List <TestStep>(); List <string> confTeams = new List <string>(); Random random = new Random(); IJavaScriptExecutor js = (IJavaScriptExecutor)driver.GetDriver(); VerifyError err = new VerifyError(); int count = 0; string[,] topPlayers = new string[10, 2] { { "", "" }, { "", "" }, { "", "" }, { "", "" }, { "", "" }, { "", "" }, { "", "" }, { "", "" }, { "", "" }, { "", "" } }; if (step.Name.Contains("Choose Top Player by Sport")) { // set teams for each conference switch (step.Data) { case "MLB": topPlayers = new string[10, 2] { { "Mike Trout", "Los Angeles Angels" }, { "Fernando Tatis Jr.", "San Diego Padres" }, { "Mookie Betts", "Los Angeles Dodgers" }, { "Bryce Harper", "Philadelphia Phillies" }, { "Aaron Judge", "New York Yankees" }, { "Freddie Freeman", "Atlanta Braves" }, { "Shane Bieber", "Cleveland Indians" }, { "Clayton Kershaw", "Los Angeles Dodgers" }, { "Trevor Bauer", "Los Angeles Dodgers" }, { "Gerrit Cole", "New York Yankees" } }; break; case "NBA": topPlayers = new string[10, 2] { { "James Harden", "Brooklyn Nets" }, { "Giannis Antetokounmpo", "Milwaukee Bucks" }, { "LeBron James", "Los Angeles Lakers" }, { "Luka Doncic", "Dallas Mavericks" }, { "Kawhi Leonard", "LA Clippers" }, { "Trae Young", "Atlanta Hawks" }, { "Anthony Davis", "Los Angeles Lakers" }, { "Anthony Edwards", "Minnesota Timberwolves" }, { "LaMelo Ball", "Charlotte Hornets" }, { "James Wiseman", "Golden State Warriors" } }; break; case "NFL": topPlayers = new string[10, 2] { { "Patrick Mahomes II", "Kansas City Chiefs" }, { "Russell Wilson", "Seattle Seahawks" }, { "Dalvin Cook", "Minnesota Vikings" }, { "Derrick Henry", "Tennessee Titans" }, { "DK Metcalf", "Seattle Seahawks" }, { "Travis Kelce", "Kansas City Chiefs" }, { "Aaron Donald", "Los Angeles Rams" }, { "Tyrann Mathieu", "Kansas City Chiefs" }, { "Justin Tucker", "Baltimore Ravens" }, { "Joe Burrow", "Cincinnati Bengals" } }; break; case "NHL": topPlayers = new string[10, 2] { { "Alex Ovechkin", "Washington Capitals" }, { "David Pastrnak", "Boston Bruins" }, { "Patrick Kane", "Chicago Blackhawks" }, { "Auston Matthews", "Toronto Maple Leafs" }, { "Artemi Panarin", "New York Rangers" }, { "Tuukka Rask", "Boston Bruins" }, { "Marc-Andre Fleury", "Vegas Golden Knights" }, { "Leon Draisaitl", "Edmonton Oilers" }, { "Andrei Vasilevskiy", "Tampa Bay Lightning" }, { "Carey Price", "Montreal Canadiens" } }; break; default: break; } // if ran once before, choose a different number if (DataManager.CaptureMap.ContainsKey("COUNT")) { do { count = random.Next(0, 10); log.Info("Random number [" + count + "] vs Stored Number [" + DataManager.CaptureMap["COUNT"] + "]"); } while (count == Int32.Parse(DataManager.CaptureMap["COUNT"])); } else { count = random.Next(0, 10); } DataManager.CaptureMap["COUNT"] = count.ToString(); DataManager.CaptureMap["TOP_PLAYER"] = topPlayers[count, 0]; DataManager.CaptureMap["TOP_PLAYER_UP"] = DataManager.CaptureMap["TOP_PLAYER"].ToUpper();; DataManager.CaptureMap["TOP_PLAYER_TEAM"] = topPlayers[count, 1]; DataManager.CaptureMap["TOP_PLAYER_TEAM_UP"] = DataManager.CaptureMap["TOP_PLAYER_TEAM"].ToUpper();; } else { throw new Exception("Test Step not found in script"); } }
public void Execute(DriverManager driver, TestStep step) { long order = step.Order; string wait = step.Wait != null ? step.Wait : ""; List <TestStep> steps = new List <TestStep>(); List <string> stoppage = new List <string>(); IWebElement ele; int size; int start; int end; int game = 0; string data = ""; string status = ""; IJavaScriptExecutor js = (IJavaScriptExecutor)driver.GetDriver(); VerifyError err = new VerifyError(); if (step.Name.Equals("Verify Box Score Tabs By Sport")) { ele = driver.FindElement("xpath", "//img[@class='location-image']"); data = ele.GetAttribute("src"); start = data.LastIndexOf('/') + 1; end = data.IndexOf(".vresize") - start; data = data.Substring(start, end); if (ele.GetAttribute("src").Contains("soccer")) { data = "Soccer"; } size = 1; switch (data) { case "Soccer": stoppage.Add("MATCHUP"); stoppage.Add(DataManager.CaptureMap["AWAY_TEAM"]); stoppage.Add(DataManager.CaptureMap["HOME_TEAM"]); break; case "NBA": case "NHL": stoppage.Add(DataManager.CaptureMap["AWAY_TEAM"]); stoppage.Add(DataManager.CaptureMap["HOME_TEAM"]); stoppage.Add("MATCHUP"); break; default: stoppage.Add(DataManager.CaptureMap["AWAY_TEAM"]); stoppage.Add(DataManager.CaptureMap["HOME_TEAM"]); break; } foreach (string stop in stoppage) { steps.Add(new TestStep(order, "Verify Box Score Links for " + data, stop, "verify_value", "xpath", "(//div[contains(@class,'boxscore')]//a)[" + size + "]", wait)); TestRunner.RunTestSteps(driver, null, steps); steps.Clear(); size++; } } else { throw new Exception("Test Step not found in script"); } }
public void Execute(DriverManager driver, TestStep step) { long order = step.Order; string wait = step.Wait != null ? step.Wait : ""; List <TestStep> steps = new List <TestStep>(); IWebElement ele; int size = 0; var length = 0; int count = 0; string objId = ""; string data = ""; string test = ""; string expected = ""; string actual = ""; bool stop = false; IJavaScriptExecutor js = (IJavaScriptExecutor)driver.GetDriver(); VerifyError err = new VerifyError(); if (step.Name.Equals("Capture Past Fight Date")) { if (!DataManager.CaptureMap.ContainsKey("PPV_FIGHT_NO")) { DataManager.CaptureMap["PPV_FIGHT_NO"] = "1"; } objId = "//div[contains(@class,'pastFights')]//div[contains(@class,'tileItem')][" + DataManager.CaptureMap["PPV_FIGHT_NO"] + "]//div[@class='date']"; DataManager.CaptureMap[step.Data] = driver.FindElement("xpath", objId).GetAttribute("innerText"); log.Info("CaptureMap variable name: " + step.Data + " will equal " + driver.FindElement("xpath", objId).GetAttribute("innerText")); } else if (step.Name.Equals("Capture Past Fight Title")) { if (!DataManager.CaptureMap.ContainsKey("PPV_FIGHT_NO")) { DataManager.CaptureMap["PPV_FIGHT_NO"] = "1"; } objId = "//div[contains(@class,'pastFights')]//div[contains(@class,'tileItem')][" + DataManager.CaptureMap["PPV_FIGHT_NO"] + "]//div[@class='title']"; DataManager.CaptureMap[step.Data] = driver.FindElement("xpath", objId).GetAttribute("innerText"); log.Info("CaptureMap variable name: " + step.Data + " will equal " + driver.FindElement("xpath", objId).GetAttribute("innerText")); } else if (step.Name.Equals("Click Past Fight Image")) { if (!DataManager.CaptureMap.ContainsKey("PPV_FIGHT_NO")) { DataManager.CaptureMap["PPV_FIGHT_NO"] = "1"; } steps.Add(new TestStep(order, "Click Past Fight Image " + DataManager.CaptureMap["PPV_FIGHT_NO"], "", "click", "xpath", "//div[contains(@class,'pastFights')]//div[contains(@class,'tileItem')][" + DataManager.CaptureMap["PPV_FIGHT_NO"] + "]//img", wait)); TestRunner.RunTestSteps(driver, null, steps); steps.Clear(); } else if (step.Name.Contains("Verify Buy Now Button")) { test = driver.FindElement("xpath", "//button[contains(@class,'formSubmit submitButton')]").GetAttribute("disabled"); if (!String.IsNullOrEmpty(test)) { stop = bool.Parse(test); } // verify button's disabled attribute is set to true if (step.Name.Contains("Disabled")) { if (stop == true) { log.Info("Verification PASSED. Disabled equals " + stop); } else { log.Error("***Verification FAILED. Expected disabled to equal true but Actual disabled field equals " + stop); err.CreateVerificationError(step, "true", stop.ToString()); driver.TakeScreenshot(DataManager.CaptureMap["TEST_ID"] + "_verification_failure_" + DataManager.VerifyErrors.Count); } } // verify button's disabled attribute is set to false else if (step.Name.Contains("Enabled")) { if (stop == false) { log.Info("Verification PASSED. Disabled equals " + stop + ". Button is enabled."); } else { log.Error("***Verification FAILED. Expected disabled to equal false but Actual disabled field equals " + stop); err.CreateVerificationError(step, "false", stop.ToString()); driver.TakeScreenshot(DataManager.CaptureMap["TEST_ID"] + "_verification_failure_" + DataManager.VerifyErrors.Count); } } } else if (step.Name.Equals("Verify PPV Entitlement")) { test = (string)js.ExecuteScript("return document.readyState;"); while (!test.Equals("complete") && size++ < 5) { log.Info("Waiting for readyState=complete"); Thread.Sleep(0500); test = (string)js.ExecuteScript("return document.readyState;"); } length = Convert.ToInt32(js.ExecuteScript("return wisRegistration.getUserEntitlements().then(x => x.ppvEvents.length)")); if (length > 0) { log.Info("PPV Entitlement Count: " + length); for (int i = 0; i < length; i++) { test = (string)js.ExecuteScript("return wisRegistration.getUserEntitlements().then(x => x.ppvEvents[" + i + "].name)"); if (step.Data.Equals(test)) { log.Info("Verification PASSED Expected Entitlement [" + step.Data + "] matches Actual Entitlement [" + test + "]"); } else { log.Error("***Verification FAILED. Expected [" + step.Data + "] does not match Actual [" + test + "]***"); err.CreateVerificationError(step, step.Data, test); } } } else { log.Error("***Verification FAILED. Expected more than 1 PPV entitlement. Current entitlement count: [" + length + "]***"); err.CreateVerificationError(step, "1 or More PPV", length.ToString()); } } else if (step.Name.Equals("Verify PPV Entitlement Count")) { Thread.Sleep(3000); log.Info("Waiting for wisRegistration..."); test = (string)js.ExecuteScript("return document.readyState;"); log.Info("wisRegistration: " + test); while (!test.Equals("complete") && size++ < 5) { log.Info("Waiting for readyState=complete"); Thread.Sleep(0500); test = (string)js.ExecuteScript("return document.readyState;"); } length = Convert.ToInt32(js.ExecuteScript("return wisRegistration.getUserEntitlements().then(x => x.ppvEvents.length)")); count = Convert.ToInt32(step.Data); if (count == length) { log.Info("Verification PASSED. Expected entitlement count [" + count + "] matches Actual entitlement count: [" + length + "]"); } else { log.Error("***Verification FAILED. Expected entitlement count [" + count + "] does not match Actual entitlement count: [" + length + "]***"); err.CreateVerificationError(step, count.ToString(), length.ToString()); } } else if (step.Name.Equals("Set Previous Fight Number")) { DataManager.CaptureMap["PPV_FIGHT_NO"] = step.Data; } else if (step.Name.Equals("Switch To Default Content")) { driver.GetDriver().SwitchTo().DefaultContent(); } else if (step.Name.Equals("Verify Event Header Title")) { expected = step.Data; expected = expected.Replace(".", string.Empty); length = expected.Length; IWebElement match = driver.FindElement("xpath", "//h1[contains(@class,'event-header-title')]"); actual = match.Text; actual = actual.Substring(0, length); if (expected.Equals(actual)) { log.Info("Verification PASSED. Expected data [" + expected + "] matches actual data [" + actual + "]"); } else { log.Error("***Verification FAILED. Expected data [" + expected + "] does not match actual data [" + actual + "] ***"); err.CreateVerificationError(step, expected, actual); driver.TakeScreenshot(DataManager.CaptureMap["TEST_ID"] + "_verification_failure_" + DataManager.VerifyErrors.Count); } } else { throw new Exception("Test Step not found in script"); } }
public void Execute(DriverManager driver, TestStep step) { long order = step.Order; string wait = step.Wait != null ? step.Wait : ""; List <TestStep> steps = new List <TestStep>(); IWebElement ele; int size = 0; var length = 0; int count = 0; string explore = ""; bool shown = false; string data = ""; List <string> channels = new List <string>(); string test = ""; bool stop = false; IJavaScriptExecutor js = (IJavaScriptExecutor)driver.GetDriver(); VerifyError err = new VerifyError(); if (step.Name.Equals("Get or Compare Device ID")) { try { test = (string)js.ExecuteScript("return document.readyState;"); while (!test.Equals("complete") && size++ < 5) { log.Info("Waiting for readyState=complete"); Thread.Sleep(0500); test = (string)js.ExecuteScript("return document.readyState;"); } data = (string)js.ExecuteScript("return window.wisRegistration.getDeviceID();"); while (String.IsNullOrEmpty(data) && count++ < 5) { log.Warn("GetDeviceID method failed. Retrying..."); Thread.Sleep(0500); data = (string)js.ExecuteScript("return window.wisRegistration.getDeviceID();"); } log.Info("Device ID equals " + data); // if device id is not stored yet, store it if (!DataManager.CaptureMap.ContainsKey("DEVICE_ID")) { DataManager.CaptureMap.Add("DEVICE_ID", data); log.Info("Storing " + data + " to CaptureMap as DEVICE_ID"); } // verify device id has not changed if (DataManager.CaptureMap["DEVICE_ID"].Equals(data)) { log.Info("Comparison PASSED. Original Device ID [" + DataManager.CaptureMap["DEVICE_ID"] + "] matches current Device ID [" + data + "]"); } else { log.Error("Comparison FAILED. Original Device ID [" + DataManager.CaptureMap["DEVICE_ID"] + "] does not match current Device ID [" + data + "]"); err.CreateVerificationError(step, DataManager.CaptureMap["DEVICE_ID"], data); } } catch (Exception e) { log.Info("ERROR: " + e); while (String.IsNullOrEmpty(data) && count++ < 5) { log.Warn("GetDeviceID method failed. Retrying..."); Thread.Sleep(0500); data = (string)js.ExecuteScript("return window.wisRegistration.getDeviceID();"); } // if device id is not stored yet, store it if (!DataManager.CaptureMap.ContainsKey("DEVICE_ID")) { DataManager.CaptureMap.Add("DEVICE_ID", data); log.Info("Storing " + data + " to CaptureMap as DEVICE_ID"); } //err.CreateVerificationError(step, "Error Capturing DeviceID", data); } } else if (step.Name.Equals("Capture User Entitlements")) { length = Convert.ToInt32(js.ExecuteScript("return wisRegistration.getUserEntitlements().then(x => x.channels.length)")); for (int i = 0; i < length; i++) { test = (string)js.ExecuteScript("return wisRegistration.getUserEntitlements().then(x => x.channels[" + i + "].name)"); channels.Add(test); log.Info("Adding channel: " + test); } log.Info("Total channel list size: " + channels.Count); DataManager.CaptureMap["ENTITLE_SIZE"] = channels.Count.ToString(); } else if (step.Name.Equals("Verify Count of User Entitlements")) { if (DataManager.CaptureMap.ContainsKey("ENTITLE_SIZE")) { if (step.Data.Equals(DataManager.CaptureMap["ENTITLE_SIZE"])) { log.Info("Verification PASSED. Expected [" + step.Data + "] matches Actual [" + DataManager.CaptureMap["ENTITLE_SIZE"] + "]"); } else { log.Error("***Verification FAILED. Expected [" + step.Data + "] does not match Actual [" + DataManager.CaptureMap["ENTITLE_SIZE"] + "]"); err.CreateVerificationError(step, step.Data, DataManager.CaptureMap["ENTITLE_SIZE"]); driver.TakeScreenshot(DataManager.CaptureMap["TEST_ID"] + "_verification_failure_" + DataManager.VerifyErrors.Count); } } else { log.Error("Cannot Verify Count without stored size"); throw new Exception("Count size not found"); } } else if (step.Name.Equals("Click Sign In With TV Provider")) { if (!DataManager.CaptureMap.ContainsKey("CURRENT_URL")) { DataManager.CaptureMap.Add("CURRENT_URL", driver.GetDriver().Url); log.Info("Storing " + driver.GetDriver().Url + " to CaptureMap as CURRENT_URL"); } else { DataManager.CaptureMap["CURRENT_URL"] = driver.GetDriver().Url; } ele = driver.FindElement("xpath", "//a[.='TV Provider Sign In']"); if (!ele.Displayed) { steps.Add(new TestStep(order, "Click Sign In Again", "", "click", "xpath", "//a[contains(@class,'sign-in')]", wait)); TestRunner.RunTestSteps(driver, null, steps); steps.Clear(); } steps.Add(new TestStep(order, "Sign In With TV Provider", "", "click", "xpath", "//a[.='TV Provider Sign In']", wait)); TestRunner.RunTestSteps(driver, null, steps); steps.Clear(); } else if (step.Name.Equals("Verify URL Redirect")) { data = driver.GetDriver().Url; log.Info("Captured URL: " + data); if (DataManager.CaptureMap.ContainsKey("CURRENT_URL")) { log.Info("CURRENT_URL value: " + DataManager.CaptureMap["CURRENT_URL"]); if (DataManager.CaptureMap["CURRENT_URL"].Equals(data)) { stop = true; } } else { log.Info("No previous URL stored. Skipping verification."); stop = true; } // verify that the url is properly redirecting while (!stop && size++ < 10) { data = driver.GetDriver().Url; log.Info("Waiting for redirect..."); Thread.Sleep(1000); if (DataManager.CaptureMap["CURRENT_URL"].Equals(data)) { log.Info("URL redirected to " + data); stop = true; } } // verify that the page is currently in a readyState test = (string)js.ExecuteScript("return document.readyState;"); while (!test.Equals("complete") && size++ < 5) { log.Info("document.readyState = " + test + ". Waiting..."); Thread.Sleep(0500); test = (string)js.ExecuteScript("return document.readyState;"); } } else if (step.Name.Equals("Navigate to Account")) { // verify that the page is currently in a readyState test = (string)js.ExecuteScript("return document.readyState;"); log.Info("document.readyState = " + test); while (!test.Equals("complete") && size++ < 8) { log.Info("Waiting..."); Thread.Sleep(0500); test = (string)js.ExecuteScript("return document.readyState;"); log.Info("document.readyState = " + test); } steps.Add(new TestStep(order, "Click Account", "", "click", "xpath", "//a[contains(@class,'account-link')]", wait)); TestRunner.RunTestSteps(driver, null, steps); steps.Clear(); count = driver.FindElements("xpath", "//div[@id='account' and contains(@class,'open')]").Count; if (count == 0) { steps.Add(new TestStep(order, "Retry Click Account", "", "click", "xpath", "//a[contains(@class,'account-link')]", wait)); TestRunner.RunTestSteps(driver, null, steps); steps.Clear(); } } else if (step.Name.Equals("Verify State of Reset Password Button")) { // verify that the button is currently enabled/disabled test = driver.FindElement("xpath", "//div[span[contains(@class,'link-text') and contains(.,'Reset Password')]]").GetAttribute("class"); test = test.Substring(test.IndexOf(" ") + 1); log.Info("button state = " + test); if (!String.IsNullOrEmpty(step.Data)) { if (step.Data.ToLower().Equals(test)) { log.Info("Verification PASSED. Expected [" + step.Data.ToLower() + "] matches Actual [" + test + "]"); } else { log.Error("***Verification FAILED. Expected [" + step.Data.ToLower() + "] does not match Actual [" + test + "]"); err.CreateVerificationError(step, step.Data.ToLower(), test); driver.TakeScreenshot(DataManager.CaptureMap["TEST_ID"] + "_verification_failure_" + DataManager.VerifyErrors.Count); } } } else if (step.Name.Equals("Capture Current URL")) { data = step.Data; if (String.IsNullOrEmpty(data)) { data = "URL"; } DataManager.CaptureMap[data] = driver.GetDriver().Url; } else if (step.Name.Equals("Click Sign In")) { while (!shown && size++ < 3) { explore = "//a[contains(@class,'sign-in')]"; steps.Add(new TestStep(order, "Click Sign In", "", "click", "xpath", explore, wait)); TestRunner.RunTestSteps(driver, null, steps); steps.Clear(); explore = driver.FindElement("xpath", "//div[@id='account']").GetAttribute("class"); log.Info("Account Container: " + explore); if (explore.Contains("open")) { shown = true; } else { shown = false; } Thread.Sleep(0500); } } else { throw new Exception("Test Step not found in script"); } }
public void Execute(DriverManager driver, TestStep step) { long order = step.Order; string wait = step.Wait != null ? step.Wait : ""; List <TestStep> steps = new List <TestStep>(); IWebElement ele; string data = ""; string xpath = ""; int count = 0; VerifyError err = new VerifyError(); string noInstancesTable = ""; bool modelInstancesTable = false; if (step.Name.Equals("Check for Model Instances Table")) { count = driver.FindElements("xpath", "//main[div[h2[.='Model Instances']]]//div[contains(@class,'text-center')]/table").Count; if (count > 0) { log.Info("Model Instances Table EXISTS. Running Table Verification Template."); steps.Add(new TestStep(order, "Run Template for Table Verification", "ModelInstancesTable", "run_template", "xpath", "", wait)); } else { log.Info("Model Instances Table DOES NOT EXIST. Verifying No Model Instances message."); steps.Add(new TestStep(order, "Verify No Table Text", "No Model instances are available for this configuration", "verify_value", "xpath", "//main[div[h2[.='Model Instances']]]//div[contains(@class,'text-center')]/span", wait)); } TestRunner.RunTestSteps(driver, null, steps); steps.Clear(); } else if (step.Name.Equals("ID Row") || step.Name.Equals("Training Job ID Row") || step.Name.Equals("Status Row") || step.Name.Equals("Training Data Timestamp Row")) { switch (step.Name) { case "ID Row": xpath = "//main[div[h2[.='Model Instances']]]//table//tr[1]//td[1]"; break; case "Training Job ID Row": xpath = "//main[div[h2[.='Model Instances']]]//table//tr[1]//td[2]"; break; case "Status Row": xpath = "//main[div[h2[.='Model Instances']]]//table//tr[1]//td[3]"; break; case "Training Data Timestamp Row": xpath = "//main[div[h2[.='Model Instances']]]//table//tr[1]//td[4]"; break; default: xpath = "//main[div[h2[.='Model Instances']]]//table//tr[1]//td"; break; } ele = driver.FindElement("xpath", xpath); data = ele.GetAttribute("textContent"); int textLength1 = data.Length; log.Info(textLength1); if (textLength1 == 0) { log.Error("***Verification Failed. " + data + " is NOT text"); err.CreateVerificationError(step, step.Name, data); driver.TakeScreenshot(DataManager.CaptureMap["TEST_ID"] + "_verification_failure_" + DataManager.VerifyErrors.Count); } else { log.Info("Verification Passed. " + data + " is text"); } } /* * xpath = "/html/body/div/main/div[10]"; * ele = driver.FindElement("xpath", xpath); * data = ele.GetAttribute("outerHTML"); * string text1 = data.ToString(); * int textLength = text1.Length; * * if (textLength > 1500) { * modelInstancesTable = true; * } * else{ * modelInstancesTable = false; * } * log.Info(modelInstancesTable); * * * if(modelInstancesTable == true){ * * if (step.Name.Equals("ID") || step.Name.Equals("Training Job ID") || step.Name.Equals("Status") || step.Name.Equals("Training Data Timestamp") || step.Name.Equals("ID Row Data") || step.Name.Equals("Training Job ID Row") || step.Name.Equals("Status Row") || step.Name.Equals("Training Data Timestamp Row")) { || || if (step.Name.Equals("ID")) { || xpath = "/html/body/div/main/div[10]/table/thead/tr/th[1]"; || } || else if (step.Name.Equals("Training Job ID")) { || xpath = "/html/body/div/main/div[10]/table/thead/tr/th[2]"; || } || else if (step.Name.Equals("Status")) { || xpath = "/html/body/div/main/div[10]/table/thead/tr/th[3]"; || } || else if (step.Name.Equals("Training Data Timestamp")) { || xpath = "/html/body/div/main/div[10]/table/thead/tr/th[4]"; || } || else if (step.Name.Equals("ID Row Data")) { || xpath = "/html/body/div/main/div[10]/table/tbody/tr/td[1]"; || } || else if (step.Name.Equals("Training Job ID Row")) { || xpath = "/html/body/div/main/div[10]/table/tbody/tr/td[2]"; || } || else if (step.Name.Equals("Status Row")) { || xpath = "/html/body/div/main/div[10]/table/tbody/tr/td[3]"; || } || else if (step.Name.Equals("Training Data Timestamp Row")) { || xpath = "/html/body/div/main/div[10]/table/tbody/tr/td[4]"; || } || || ele = driver.FindElement("xpath", xpath); || data = ele.GetAttribute("textContent"); || string text = data.ToString(); || int textLength1 = text.Length; || log.Info(textLength1); || if(textLength1 == 0) { || log.Error("***Verification Failed." + text + "is NOT text"); || err.CreateVerificationError(step, xpath, text); || driver.TakeScreenshot(DataManager.CaptureMap["TEST_ID"] + "_verification_failure_" + DataManager.VerifyErrors.Count); || } || else { || log.Info("Verification Passed." + text + "is text"); || || } || } || else { || xpath = "/html/body/div/main/div[10]/span"; || ele = driver.FindElement("xpath", xpath); || data = ele.GetAttribute("textContent"); || string text = data.ToString(); || log.Info(text); || || || if(text != "No Model instances are available for this configuration") { || log.Error("***Verification Failed. Table not present and incorrect message text."); || err.CreateVerificationError(step, xpath, text); || driver.TakeScreenshot(DataManager.CaptureMap["TEST_ID"] + "_verification_failure_" + DataManager.VerifyErrors.Count); || } || else { || log.Info("Verification Passed. Table is not present but text is present: No Model instances are available for this configuration"); || || } || || || } ||}*/ else { throw new Exception("Test Step not found in script"); } }
public void Execute(DriverManager driver, TestStep step) { long order = step.Order; string wait = step.Wait != null ? step.Wait : ""; List <TestStep> steps = new List <TestStep>(); IWebElement ele; int size; int variable; int scrolls = 20; int months = 0; int year = 0; string date = ""; string data = ""; string odd = ""; string status = ""; string title; string xpath = ""; bool stop = false; bool playoff = false; IJavaScriptExecutor js = (IJavaScriptExecutor)driver.GetDriver(); VerifyError err = new VerifyError(); if (step.Name.Equals("Verify Displayed Day on Top Scores")) { TimeSpan time = DateTime.UtcNow.TimeOfDay; int now = time.Hours; int et = now - 4; if (et >= 0 && et < 11) { log.Info("Current Eastern Time hour is " + et + ". Default to Yesterday."); step.Data = "YESTERDAY"; DataManager.CaptureMap["TOP_DATE"] = "Yesterday"; } else { log.Info("Current Eastern Time hour is " + et + ". Default to Today."); step.Data = "TODAY"; DataManager.CaptureMap["TOP_DATE"] = "Today"; } steps.Add(new TestStep(order, "Verify Displayed Day on Top Scores", step.Data, "verify_value", "xpath", "//div[contains(@class,'scores-date')]//div[contains(@class,'sm')]", wait)); TestRunner.RunTestSteps(driver, null, steps); steps.Clear(); } else if (step.Name.Equals("Scroll Top Scores Page to Yesterday")) { title = "//div[contains(@class,'section-subtitle')]"; ele = driver.FindElement("xpath", title); date = ele.GetAttribute("innerText"); if (!date.Equals("YESTERDAY")) { do { js.ExecuteScript("window.scrollBy({top: -100,left: 0,behavior: 'smooth'});"); log.Info("Scrolling up on page..."); ele = driver.FindElement("xpath", title); date = ele.GetAttribute("innerText"); log.Info(scrolls + " scrolls until limit is reached"); }while (!date.Equals("YESTERDAY") && scrolls-- > 0); steps.Add(new TestStep(order, "Verify Displayed Day on Top Scores", "YESTERDAY", "verify_value", "xpath", title, wait)); TestRunner.RunTestSteps(driver, null, steps); steps.Clear(); DataManager.CaptureMap["SCROLLED"] = "YES"; } else { log.Info("Page defaulted to YESTERDAY"); } } else if (step.Name.Equals("Scroll Top Scores Page Down to Today")) { title = "//div[contains(@class,'scores-date')]//div[contains(@class,'sm')]"; ele = driver.FindElement("xpath", title); date = ele.GetAttribute("innerText"); if (!date.Equals("TODAY")) { do { js.ExecuteScript("window.scrollBy({top: 100,left: 0,behavior: 'smooth'});"); log.Info("Scrolling down on page..."); ele = driver.FindElement("xpath", title); date = ele.GetAttribute("innerText"); log.Info(scrolls + " scrolls until limit is reached"); }while (!date.Equals("TODAY") && scrolls-- > 0); steps.Add(new TestStep(order, "Verify Displayed Day on Top Scores", "TODAY", "verify_value", "xpath", title, wait)); TestRunner.RunTestSteps(driver, null, steps); steps.Clear(); DataManager.CaptureMap["SCROLLED"] = "YES"; } else { log.Info("Page defaulted to TODAY"); } } else if (step.Name.Equals("Scroll Top Scores Page to Tomorrow")) { title = "//div[contains(@class,'scores-date') or contains(@class,'week-selector')]//*[contains(@class,'sm-14')]"; ele = driver.FindElement("xpath", title); date = ele.GetAttribute("innerText"); if (!date.Equals("TOMORROW")) { do { js.ExecuteScript("window.scrollBy({top: 100,left: 0,behavior: 'smooth'});"); log.Info("Scrolling down on page..."); ele = driver.FindElement("xpath", title); date = ele.GetAttribute("innerText"); log.Info(scrolls + " scrolls until limit is reached"); }while (!date.Equals("TOMORROW") && scrolls-- > 0); steps.Add(new TestStep(order, "Verify Displayed Day on Top Scores", "TOMORROW", "verify_value", "xpath", title, wait)); TestRunner.RunTestSteps(driver, null, steps); steps.Clear(); DataManager.CaptureMap["SCROLLED"] = "YES"; } else { log.Info("Page defaulted to TOMORROW"); } } else if (step.Name.Equals("Verify Odds Info on Chip")) { data = step.Data; for (int odds = 1; odds <= 2; odds++) { switch (odds) { case 1: date = "//a[contains(@class,'score-chip')][" + data + "]"; xpath = "//a[contains(@class,'score-chip')][" + data + "]//div[contains(@class,'odds')]//span[contains(@class,'secondary-text status')]"; status = "Spread"; break; case 2: date = "//a[contains(@class,'score-chip')][" + data + "]"; xpath = "//a[contains(@class,'score-chip')][" + data + "]//div[contains(@class,'odds')]//span[contains(@class,'secondary-text ffn')]"; status = "Total"; break; default: break; } ele = driver.FindElement("xpath", xpath); odd = ele.GetAttribute("innerText"); title = driver.FindElement("xpath", date).GetAttribute("href"); title = title.Substring(title.IndexOf("?") + 1); if (!String.IsNullOrEmpty(odd)) { log.Info("Score Chip " + data + " (" + title + ") " + status + " equals " + odd); } else { log.Error("VERIFICATION FAILED: Score Chip " + data + " (" + title + ") " + status + " is blank "); err.CreateVerificationError(step, "Event " + title + " Missing " + status, odd); driver.TakeScreenshot(DataManager.CaptureMap["TEST_ID"] + "_verification_failure_" + DataManager.VerifyErrors.Count); } } } else if (step.Name.Equals("Verify League Title on Top Scores")) { switch (step.Data) { case "Scorestrip": title = "//div[contains(@class,'homepage-module')]//a[contains(@class,'score-chip')]"; break; case "Yesterday": title = DateTime.Today.AddDays(-1).ToString("yyyyMMdd"); title = "//div[@id='" + title + "']//a[contains(@class,'score-chip')]"; break; case "Today": title = DateTime.Today.ToString("yyyyMMdd"); title = "//div[@id='" + title + "']//a[contains(@class,'score-chip')]"; break; case "Tomorrow": title = DateTime.Today.AddDays(+1).ToString("yyyyMMdd"); title = "//div[@id='" + title + "']//a[contains(@class,'score-chip')]"; break; default: title = "//div[@class='scores']//a[contains(@class,'score-chip')]"; break; } size = driver.FindElements("xpath", title).Count; for (int i = 1; i <= size; i++) { ele = driver.FindElement("xpath", "(" + title + "//div[@class='highlight-text']//div[contains(@class,'league-title')])[" + i + "]"); data = ele.GetAttribute("innerText"); if (!String.IsNullOrEmpty(data)) { log.Info("Score Chip " + i + " League Title equals " + data); } else { err.CreateVerificationError(step, "Expected League Title", data); } } } else if (step.Name.Equals("Click Scorechip By Number")) { data = step.Data; if (DataManager.CaptureMap.ContainsKey("SCROLLED")) { xpath = "//div[contains(@class,'score-section')][div[@class='scores-date'][not(div)]]"; } steps.Add(new TestStep(order, "Click Event " + data, "", "click", "xpath", xpath + "//a[contains(@class,'score-chip')][" + data + "]", wait)); TestRunner.RunTestSteps(driver, null, steps); steps.Clear(); } else if (step.Name.Equals("Capture Team Info from Chip")) { data = step.Data; if (DataManager.CaptureMap.ContainsKey("SCROLLED")) { xpath = "//div[contains(@class,'score-section')][div[@class='scores-date'][not(div)]]"; } if (driver.FindElements("xpath", "//a[contains(@class,'score-chip-playoff')]").Count > 0) { playoff = true; } if (playoff) { steps.Add(new TestStep(order, "Capture Away Team", "AWAY_TEAM", "capture", "xpath", "(" + xpath + "//a[contains(@class,'score-chip-playoff')][" + data + "]//div[@class='team-texts']//span[contains(@class,'team-name-1')])[1]", wait)); steps.Add(new TestStep(order, "Capture Home Team", "HOME_TEAM", "capture", "xpath", "(" + xpath + "//a[contains(@class,'score-chip-playoff')][" + data + "]//div[@class='team-texts']//span[contains(@class,'team-name-2')])[1]", wait)); } else { steps.Add(new TestStep(order, "Capture Away Team Abbreviation", "AWAY_TEAM_ABB", "capture", "xpath", "(" + xpath + "//a[contains(@class,'score-chip')][" + data + "]//div[@class='teams']//div[contains(@class,'abbreviation')]//span[contains(@class,'text')])[1]", wait)); steps.Add(new TestStep(order, "Capture Away Team", "AWAY_TEAM", "capture", "xpath", "(" + xpath + "//a[contains(@class,'score-chip')][" + data + "]//div[@class='teams']//div[contains(@class,' team')]//span[contains(@class,'text')])[1]", wait)); steps.Add(new TestStep(order, "Capture Home Team Abbreviation", "HOME_TEAM_ABB", "capture", "xpath", "(" + xpath + "//a[contains(@class,'score-chip')][" + data + "]//div[@class='teams']//div[contains(@class,'abbreviation')]//span[contains(@class,'text')])[2]", wait)); steps.Add(new TestStep(order, "Capture Home Team", "HOME_TEAM", "capture", "xpath", "(" + xpath + "//a[contains(@class,'score-chip')][" + data + "]//div[@class='teams']//div[contains(@class,' team')]//span[contains(@class,'text')])[2]", wait)); } // capture scores for event if (DataManager.CaptureMap["EVENT_STATUS"].Equals("LIVE") || DataManager.CaptureMap["EVENT_STATUS"].Equals("FINAL")) { if (playoff) { steps.Add(new TestStep(order, "Capture Away Team Score", "AWAY_TEAM_SCORE", "capture", "xpath", "(" + xpath + "//a[contains(@class,'score-chip-playoff')][" + data + "]//div[contains(@class,'score')]//span[contains(@class,'score-1')])[1]", wait)); steps.Add(new TestStep(order, "Capture Home Team Score", "HOME_TEAM_SCORE", "capture", "xpath", "(" + xpath + "//a[contains(@class,'score-chip-playoff')][" + data + "]//div[contains(@class,'score')]//span[contains(@class,'score-2')])[1]", wait)); } else { steps.Add(new TestStep(order, "Capture Away Team Score", "AWAY_TEAM_SCORE", "capture", "xpath", "(" + xpath + "//a[contains(@class,'score-chip')][" + data + "]//div[@class='teams']//div[contains(@class,'team-score')])[1]", wait)); steps.Add(new TestStep(order, "Capture Home Team Score", "HOME_TEAM_SCORE", "capture", "xpath", "(" + xpath + "//a[contains(@class,'score-chip')][" + data + "]//div[@class='teams']//div[contains(@class,'team-score')])[2]", wait)); } } TestRunner.RunTestSteps(driver, null, steps); steps.Clear(); } else if (step.Name.Equals("Click NBA") || step.Name.Equals("Click NCAA BK") || step.Name.Equals("Click MLB") || step.Name.Equals("Click NASCAR") || step.Name.Equals("Click Soccer") || step.Name.Equals("Click NHL") || step.Name.Equals("Click Boxing") || step.Name.Equals("Click NCAA FB") || step.Name.Equals("Click NFL") || step.Name.Equals("Click Golf") || step.Name.Equals("Click Sport by Name") || step.Name.Equals("Verify Selected Category")) { if (step.Name.Equals("Verify Selected Category") || step.Name.Equals("Click Sport by Name")) { data = step.Data; } else { data = step.Name.Substring(6); } switch (data) { case "NBA": xpath = "//div[contains(@class,'desktop')]//a[not(contains(@class,'more-button')) and contains(.,'NBA')]"; break; case "NCAA BK": xpath = "//div[contains(@class,'desktop')]//a[not(contains(@class,'more-button')) and contains(.,'NCAA BK')]"; break; case "MLB": xpath = "//div[contains(@class,'desktop')]//a[not(contains(@class,'more-button')) and contains(.,'MLB')]"; break; case "NASCAR": xpath = "//div[contains(@class,'desktop')]//a[not(contains(@class,'more-button')) and contains(.,'NASCAR')]"; break; case "Soccer": case "SOCCER": xpath = "//div[contains(@class,'desktop')]//a[not(contains(@class,'more-button')) and contains(.,'SOCCER')]"; break; case "NHL": xpath = "//div[contains(@class,'desktop')]//a[not(contains(@class,'more-button')) and contains(.,'NHL')]"; break; case "Boxing": case "BOXING": xpath = "//div[contains(@class,'desktop')]//a[not(contains(@class,'more-button')) and contains(.,'BOXING')]"; break; case "NCAA FB": xpath = "//div[contains(@class,'desktop')]//a[not(contains(@class,'more-button')) and contains(.,'NCAA FB')]"; break; case "NFL": xpath = "//div[contains(@class,'desktop')]//a[not(contains(@class,'more-button')) and contains(.,'NFL')]"; break; case "Golf": case "GOLF": xpath = "//div[contains(@class,'desktop')]//a[not(contains(@class,'more-button')) and contains(.,'GOLF')]"; break; default: xpath = "//div[contains(@class,'desktop')]//a[contains(.,'TOP')]"; break; } stop = driver.FindElement("xpath", xpath).Displayed; // verify selected category. otherwise, click appropriate scores sport. if (step.Name.Equals("Verify Selected Category")) { if (!stop) { step.Data = "MORE"; } steps.Add(new TestStep(order, "Verify Selected Tab", step.Data, "verify_value", "xpath", "//div[contains(@class,'desktop')]//*[contains(@class,'selected')]", wait)); TestRunner.RunTestSteps(driver, null, steps); steps.Clear(); } else { if (!stop) { steps.Add(new TestStep(order, "Open MORE", "", "click", "xpath", "//div[contains(@class,'desktop')]//button[contains(@class,'more-button')]", wait)); } steps.Add(new TestStep(order, "Click " + data, "", "click", "xpath", xpath, wait)); TestRunner.RunTestSteps(driver, null, steps); steps.Clear(); } if (DataManager.CaptureMap.ContainsKey("SCROLLED")) { DataManager.CaptureMap.Remove("SCROLLED"); } } else if (step.Name.Equals("Verify Selected Date")) { switch (step.Data) { case "CBK": size = 3; break; case "CFB": size = 12; break; case "Golf": case "GOLF": size = 11; break; case "MLB": size = 9; break; case "NASCAR": size = 11; break; case "NBA": size = 4; break; case "NHL": size = 4; break; case "NFL": size = 12; break; case "Soccer": case "SOCCER": size = 12; break; default: size = 12; break; } if (DataManager.CaptureMap.ContainsKey("MONTH") && DataManager.CaptureMap.ContainsKey("DATE")) { months = DateTime.ParseExact(DataManager.CaptureMap["MONTH"], "MMMM", CultureInfo.CurrentCulture).Month; if (months > size) { year = DateTime.Now.Year - 1; } else { year = DateTime.Now.Year; } log.Info("Event Year: " + year); DateTime chosen = new DateTime(year, months, Int32.Parse(DataManager.CaptureMap["DATE"])); data = chosen.DayOfWeek.ToString(); data = data.Substring(0, 3).ToUpper() + ", " + DataManager.CaptureMap["MONTH"].Substring(0, 3) + " " + DataManager.CaptureMap["DATE"]; } else if (DataManager.CaptureMap.ContainsKey("WEEK") && DataManager.CaptureMap.ContainsKey("WEEK_DATES")) { if (DataManager.CaptureMap["WEEK_DATES"].Length >= 5) { data = DataManager.CaptureMap["WEEK_DATES"].Substring(0, 6); } else { data = DataManager.CaptureMap["WEEK_DATES"]; } if (DataManager.CaptureMap.ContainsKey("IN_SEASON")) { if (Convert.ToBoolean(DataManager.CaptureMap["IN_SEASON"])) { year = DateTime.Now.Year; } else { year = DateTime.Now.Year - 1; } } data = DataManager.CaptureMap["WEEK"].Trim() + " - THU, " + data.Trim(); } steps.Add(new TestStep(order, "Selected Date Check", data, "verify_value", "xpath", "//button[contains(@class,'date-picker-title') or contains(@class,'dropdown-title')]", "5")); TestRunner.RunTestSteps(driver, null, steps); steps.Clear(); } else if (step.Name.Equals("Store Current Number of Score Sections")) { title = "//div[contains(@class,'score-section')]"; size = driver.FindElements("xpath", title).Count; log.Info("Storing number of Scores sections displayed: " + size); if (DataManager.CaptureMap.ContainsKey("SCORE_SECTIONS")) { DataManager.CaptureMap["SCORE_SECTIONS"] = size.ToString(); } else { DataManager.CaptureMap.Add("SCORE_SECTIONS", size.ToString()); } } else if (step.Name.Equals("Verify Number of Score Sections")) { if (DataManager.CaptureMap.ContainsKey("SCORE_SECTIONS") && step.Data.Contains("+")) { stop = int.TryParse(DataManager.CaptureMap["SCORE_SECTIONS"], out size); stop = int.TryParse(step.Data.Substring(step.Data.IndexOf("+") + 1), out variable); size = size + variable; step.Data = size.ToString(); } steps.Add(new TestStep(order, "Verify Sections", step.Data, "verify_count", "xpath", "//div[contains(@class,'score-section')]", "")); TestRunner.RunTestSteps(driver, null, steps); steps.Clear(); } else if (step.Name.Equals("Scroll Back One Day")) { status = "//div[contains(@class,'scores-app-root')]/div[not(@style='display: none;')]//div[contains(@class,'week-selector')]"; date = driver.FindElement("xpath", status).Text; DataManager.CaptureMap["CURRENT"] = date; log.Info("Current Day: " + date); if (date.Equals("TODAY")) { DataManager.CaptureMap["PREVIOUS"] = "YESTERDAY"; } else if (date.Equals("YESTERDAY")) { var today = DateTime.Now; var yesterday = today.AddDays(-2); DataManager.CaptureMap["PREVIOUS"] = yesterday.ToString("ddd, MMM d").ToUpper(); } else { var num = int.Parse(date.Substring(10)); num = num--; var old = new DateTime(DateTime.Now.Year, DateTime.Now.Month, num); DataManager.CaptureMap["PREVIOUS"] = old.ToString("ddd, MMM d").ToUpper(); } do { js.ExecuteScript("window.scrollBy({top: -100,left: 0,behavior: 'smooth'});"); log.Info("Scrolling up on page..."); date = driver.FindElement("xpath", status).Text; log.Info("Current Day: " + date); log.Info(scrolls + " scrolls until limit is reached"); } while (date.Equals(DataManager.CaptureMap["CURRENT"]) && scrolls-- > 0); DataManager.CaptureMap["SCROLLED"] = "YES"; } else if (step.Name.Equals("Scroll Forward One Day")) { status = "//div[contains(@class,'scores-app-root')]/div[not(@style='display: none;')]//div[contains(@class,'week-selector')]"; date = driver.FindElement("xpath", status).Text; DataManager.CaptureMap["CURRENT"] = date; log.Info("Current Day: " + date); if (date.Equals("TODAY")) { DataManager.CaptureMap["NEXT"] = "TOMORROW"; } else if (date.Equals("YESTERDAY")) { DataManager.CaptureMap["NEXT"] = "TODAY"; } else if (date.Equals("TOMORROW")) { var today = DateTime.Now; var yesterday = today.AddDays(2); DataManager.CaptureMap["NEXT"] = yesterday.ToString("ddd, MMM d").ToUpper(); } else { var num = int.Parse(date.Substring(10)); num = num++; var old = new DateTime(DateTime.Now.Year, DateTime.Now.Month, num); DataManager.CaptureMap["NEXT"] = old.ToString("ddd, MMM d").ToUpper(); } do { js.ExecuteScript("window.scrollBy({top: 100,left: 0,behavior: 'smooth'});"); log.Info("Scrolling down on page..."); date = driver.FindElement("xpath", status).Text; log.Info("Current Day: " + date); log.Info(scrolls + " scrolls until limit is reached"); } while (date.Equals(DataManager.CaptureMap["CURRENT"]) && scrolls-- > 0); DataManager.CaptureMap["SCROLLED"] = "YES"; } else { throw new Exception("Test Step not found in script"); } }
public void Execute(DriverManager driver, TestStep step) { long order = step.Order; string wait = step.Wait != null ? step.Wait : ""; List <TestStep> steps = new List <TestStep>(); IWebElement ele; string month = ""; string data = ""; string xpath = ""; VerifyError err = new VerifyError(); IJavaScriptExecutor js = (IJavaScriptExecutor)driver.GetDriver(); OpenQA.Selenium.Interactions.Actions actions = new OpenQA.Selenium.Interactions.Actions(driver.GetDriver()); string[] nascarGroups = { "CUP SERIES", "CAMPING WORLD TRUCK SERIES", "XFINITY SERIES" }; if (step.Name.Equals("Verify NASCAR Groups")) { data = "//div[contains(@class,'scores-home-container')]//div[contains(@class,'active')]//ul"; steps.Add(new TestStep(order, "Open Conference Dropdown", "", "click", "xpath", "//a[@class='dropdown-menu-title']", wait)); steps.Add(new TestStep(order, "Verify Dropdown is Displayed", "", "verify_displayed", "xpath", data, wait)); TestRunner.RunTestSteps(driver, null, steps); steps.Clear(); data = data + "//li"; steps.Add(new TestStep(order, "Verify Number of Groups", "3", "verify_count", "xpath", data, wait)); TestRunner.RunTestSteps(driver, null, steps); steps.Clear(); var groups = driver.FindElements("xpath", data); for (int i = 0; i < groups.Count; i++) { if (nascarGroups[i].Equals(groups[i].GetAttribute("innerText"))) { log.Info("Success. " + nascarGroups[i] + " matches " + groups[i].GetAttribute("innerText")); } else { log.Error("***Verification FAILED. Expected data [" + nascarGroups[i] + "] does not match actual data [" + groups[i].GetAttribute("innerText") + "] ***"); err.CreateVerificationError(step, nascarGroups[i], groups[i].GetAttribute("innerText")); } } } else if (step.Name.Equals("Determine Current Race")) { month = DateTime.Now.Month.ToString("00"); // determine week of season by today's month steps.Add(new TestStep(order, "Collect Bifrost Info", month, "script", "xpath", "Bifrost", wait)); TestRunner.RunTestSteps(driver, null, steps); steps.Clear(); xpath = "//div[@id='" + DataManager.CaptureMap["IND_EVENTID"] + "']"; ele = driver.FindElement("xpath", xpath); js.ExecuteScript("arguments[0].scrollIntoView(true);", ele); log.Info("*TEMPORARY FIX* : Scroll to Score Chip " + data); } else { throw new Exception("Test Step not found in script"); } }
public void Execute(DriverManager driver, TestStep step) { long order = step.Order; string wait = step.Wait != null ? step.Wait : ""; IWebElement ele; IJavaScriptExecutor js = (IJavaScriptExecutor)driver.GetDriver(); int eleCount = 0; int total; int size = 0; int scrolls = 20; string date = ""; string cat = ""; bool displayed = false; List <string> categories = new List <string>(); List <TestStep> steps = new List <TestStep>(); VerifyError err = new VerifyError(); TextInfo ti = new CultureInfo("en-US", false).TextInfo; if (step.Name.Equals("Click Arrow Forward to End of Carousel")) { eleCount = driver.FindElements("xpath", "//div[not(contains(@class,'scorestrip')) and contains(@class,'carousel-wrapper') and contains(@class,'can-scroll-right')]").Count; while (eleCount > 0) { steps.Add(new TestStep(order, "Click Arrow Forward", "", "click", "xpath", "//button[@class='carousel-button-next image-button']", wait)); TestRunner.RunTestSteps(driver, null, steps); steps.Clear(); eleCount = driver.FindElements("xpath", "//div[contains(@class,'carousel') and contains(@class,'can-scroll-right')]").Count; } } else if (step.Name.Equals("Verify Number of Story Cards")) { try { total = Int32.Parse(step.Data); } catch (Exception e) { total = 50; log.Error("Expected data to be a numeral. Setting data to 50."); } size = driver.FindElements("xpath", "//div[contains(@class,'cards-slide')]//a[contains(@class,'card-story')]").Count; if (size >= total && size <= 100) { log.Info("Verification PASSED. Total Stories [" + size + "] is between " + total + " and 100."); } else { log.Error("***Verification FAILED. " + size + " is not between " + total + " and 100***"); err.CreateVerificationError(step, ">= " + total + " & <= 100", size.ToString()); } } else if (step.Name.Equals("Verify Story Date")) { date = driver.FindElement("xpath", "//div[contains(@class,'info-text')]").Text; if (date.Contains("•")) { date = date.Substring(date.IndexOf("•") + 2); } if (date.Equals(step.Data)) { log.Info("Verification PASSED. Expected value [" + step.Data + "] equals actual value [" + date + "]"); } else if (date.Contains("MINS AGO") && step.Data.Contains("MINS AGO")) { log.Info("Verification PASSED. [" + step.Data + "] refers to same value as [" + date + "]"); } else { log.Error("***Verification FAILED. Expected [" + step.Data + "] does not equal actual value [" + date + "]***"); err.CreateVerificationError(step, step.Data, date); } } else if (step.Name.Contains("Stories Category by Sport")) { switch (step.Data) { case "NFL": string[] nfl_teams = { "NATIONAL FOOTBALL LEAGUE", "ARIZONA CARDINALS", "ATLANTA FALCONS", "BALTIMORE RAVENS", "BUFFALO BILLS", "CAROLINA PANTHERS", "CHICAGO BEARS", "CINCINNATI BENGALS", "CLEVELAND BROWNS", "DALLAS COWBOYS", "DENVER BRONCOS", "DETROIT LIONS", "GREEN BAY PACKERS", "HOUSTON TEXANS", "INDIANAPOLIS COLTS", "JACKSONVILLE JAGUARS", "KANSAS CITY CHIEFS", "LAS VEGAS RAIDERS", "LOS ANGELES CHARGERS", "LOS ANGELES RAMS", "MIAMI DOLPHINS", "MINNESOTA VIKINGS", "NEW ENGLAND PATRIOTS", "NEW ORLEANS SAINTS", "NEW YORK GIANTS", "NEW YORK JETS", "PHILADELPHIA EAGLES", "PITTSBURGH STEELERS", "SAN FRANCISCO 49ERS", "SEATTLE SEAHAWKS", "TAMPA BAY BUCCANEERS", "TENNESSEE TITANS", "WASHINGTON FOOTBALL TEAM" }; string[] nfl_players = { "CAM NEWTON", "PATRICK MAHOMES II", "TOM BRADY", "TUA TAGOVAILOA", "DAK PRESCOTT", "ALEX SMITH", "GEORGE KITTLE", "TEDDY BRIDGEWATER", "JOE BURROW", "BAKER MAYFIELD", "LAMAR JACKSON" }; categories.AddRange(nfl_teams); categories.AddRange(nfl_players); break; case "NBA": string[] nba_teams = { "NATIONAL BASKETBALL ASSOCIATION", "ATLANTA HAWKS", "BOSTON CELTICS", "BROOKLYN NETS", "CHARLOTTE HORNETS", "CHICAGO BULLS", "CLEVELAND CAVALIERS", "DALLAS MAVERICKS", "DENVER NUGGETS", "DETROIT PISTONS", "GOLDEN STATE WARRIORS", "HOUSTON ROCKETS", "INDIANA PACERS", "LOS ANGELES CLIPPERS", "LOS ANGELES LAKERS", "MEMPHIS GRIZZLIES", "MIAMI HEAT", "MILWAUKEE BUCKS", "MINNESOTA TIMBERWOLVES", "NEW ORLEANS PELICANS", "NEW YORK KNICKS", "OKLAHOMA CITY THUNDER", "ORLANDO MAGIC", "PHILADELPHIA 76ERS", "PHOENIX SUNS", "PORTLAND TRAIL BLAZERS", "SACRAMENTO KINGS", "SAN ANTONIO SPURS", "TORONTO RAPTORS", "UTAH JAZZ", "WASHINGTON WIZARDS" }; string[] nba_players = { "LEBRON JAMES", "KEVIN DURANT", "JAMES HARDEN", "KYRIE IRVING", "LAMELO BALL" }; categories.AddRange(nba_teams); categories.AddRange(nba_players); break; case "NHL": break; case "MLB": string[] mlb = { "MAJOR LEAGUE BASEBALL", "ARIZONA DIAMONDBACKS", "ATLANTA BRAVES", "BALTIMORE ORIOLES", "BOSTON RED SOX", "CHICAGO CUBS", "CHICAGO WHITE SOX", "CINCINNATI REDS", "CLEVELAND INDIANS", "COLORADO ROCKIES", "DETROIT TIGERS", "HOUSTON ASTROS", "KANSAS CITY ROYALS", "LOS ANGELES ANGELS", "LOS ANGELES DODGERS", "MIAMI MARLINS", "MILWAUKEE BREWERS", "MINNESOTA TWINS", "NEW YORK METS", "NEW YORK YANKEES", "OAKLAND ATHLETICS", "PHILADELPHIA PHILLIES", "PITTSBURGH PIRATES", "SAN DIEGO PADRES", "SAN FRANCISCO GIANTS", "SEATTLE MARINERS", "ST. LOUIS CARDINALS", "TAMPA BAY RAYS", "TEXAS RANGERS", "TORONTO BLUE JAYS", "WASHINGTON NATIONALS" }; categories.AddRange(mlb); break; case "NCAA FB": string[] cfb = { "COLLEGE FOOTBALL" }; categories.AddRange(cfb); break; default: break; } size = driver.FindElements("xpath", "//div[contains(@class,'cards-slide-')]//a[contains(@class,'card-story')]").Count; for (int i = 1; i <= size; i++) { if (i == 4 && step.Name.Contains("Carousel")) { ele = driver.FindElement("xpath", "//div[contains(@class,'carousel-wrapper')]"); js.ExecuteScript("arguments[0].scrollIntoView(true);", ele); steps.Add(new TestStep(order, "Scroll Carousel Right", "", "click", "xpath", "//button[contains(@class,'carousel-button-next')]", wait)); TestRunner.RunTestSteps(driver, null, steps); steps.Clear(); } cat = driver.FindElement("xpath", "(//div[contains(@class,'card-grid-header')])[" + i + "]").Text; if (categories.Contains(cat)) { log.Info("Story " + i + " Passed. Category [" + cat + "] falls under " + step.Data); } else { log.Error("***VERIFICATION FAILED. Story " + i + ". Category [" + cat + "] DOES NOT fall under " + step.Data); err.CreateVerificationError(step, cat, step.Data); driver.TakeScreenshot(DataManager.CaptureMap["TEST_ID"] + "_verification_failure_" + DataManager.VerifyErrors.Count); } } } else if (step.Name.Equals("Verify Tag Exists by Name")) { steps.Add(new TestStep(order, "Verify Tag", "", "verify_displayed", "xpath", "//div[contains(@class,'story-topic-group')]//span[.='" + ti.ToTitleCase(step.Data.ToLower()) + "']", wait)); TestRunner.RunTestSteps(driver, null, steps); steps.Clear(); } else if (step.Name.Equals("Scroll Through Story")) { ele = driver.FindElement("xpath", "//div[@class='story-favorites-section-add']"); js.ExecuteScript("arguments[0].scrollIntoView(true);", ele); log.Info("Scrolling down on page..."); } else { log.Warn("Test Step not found in script..."); } }