public RootProcessor( [Import] ICompositionService composition, [Import] RnetBus bus, [Import] DriverManager driverManager, [Import] ProfileManager profileManager, [ImportMany] IEnumerable<Lazy<IRequestProcessor, RequestProcessorMetadata>> requestProcessors, [ImportMany] IEnumerable<Lazy<IResponseProcessor, ResponseProcessorMetadata>> responseProcessors) { Contract.Requires<ArgumentNullException>(composition != null); Contract.Requires<ArgumentNullException>(bus != null); Contract.Requires<ArgumentNullException>(requestProcessors != null); Contract.Requires<ArgumentNullException>(responseProcessors != null); Contract.Requires<ArgumentNullException>(driverManager != null); Contract.Requires<ArgumentNullException>(profileManager != null); this.composition = composition; this.bus = bus; this.driverManager = driverManager; this.profileManager = profileManager; this.requestProcessors = requestProcessors; this.responseProcessors = responseProcessors; }
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; DateTime start; DateTime end; DateTime now; string data = ""; bool season = false; IJavaScriptExecutor js = (IJavaScriptExecutor)driver.GetDriver(); VerifyError err = new VerifyError(); if (step.Name.Equals("Is Sport In-Season?")) { now = DateTime.Today; switch (step.Data) { case "CBK": start = new DateTime(2020, 11, 24); end = new DateTime(2021, 04, 05); break; case "CFB": start = new DateTime(2020, 08, 19); end = new DateTime(2021, 01, 11); break; case "Golf": case "GOLF": start = new DateTime(2021, 01, 07); end = new DateTime(2021, 09, 05); break; case "MLB": start = new DateTime(2021, 04, 01); end = new DateTime(2021, 10, 28); break; case "NASCAR": start = new DateTime(2021, 02, 09); end = new DateTime(2021, 11, 07); break; case "NBA": start = new DateTime(2020, 12, 11); end = new DateTime(2021, 08, 01); break; case "NHL": start = new DateTime(2021, 01, 12); end = new DateTime(2021, 05, 30); break; case "NFL": start = new DateTime(2020, 08, 01); end = new DateTime(2021, 02, 02); break; case "Soccer": case "SOCCER": start = new DateTime(2020, 11, 05); end = new DateTime(2021, 11, 05); break; default: start = new DateTime(2020, 11, 05); end = new DateTime(2021, 11, 05); break; } log.Info("Current date: " + now); if (now >= start && now < end) { DataManager.CaptureMap.Add("IN_SEASON", "True"); log.Info("Today is in-season. Storing IN_SEASON to Capture Map as True."); } else { DataManager.CaptureMap.Add("IN_SEASON", "False"); log.Info("Today is not in-season. Storing IN_SEASON to Capture Map as False."); } } else { throw new Exception("Test Step not found in script"); } }
public void Execute(DriverManager driver, TestStep step) { long order = step.Order; IWebElement ele; string data = ""; string xpath = ""; VerifyError err = new VerifyError(); if (step.Name.Equals("Mock Training Data Timestamp Input") || step.Name.Equals("Mock Prediction Data Timestamp Input")) { if (step.Name.Equals("Mock Training Data Timestamp Input")) { xpath = "//input[@id='TrainingDataTimestamp']"; } else if (step.Name.Equals("Mock Prediction Data Timestamp Input")) { xpath = "//input[@id='PredictionDataTimestamp']"; } ele = driver.FindElement("xpath", xpath); data = ele.GetAttribute("value"); DateTime dDate; if (DateTime.TryParse(data, out dDate)) { String.Format("MM/d/yyyy H:mm:sszzz", dDate); string eDate = dDate.ToString(); if (data == eDate) { log.Info("Verification Passed." + data + "is in the correct format"); } else { log.Error("***Verification Failed." + data + "does not equal" + eDate); err.CreateVerificationError(step, eDate, data); driver.TakeScreenshot(DataManager.CaptureMap["TEST_ID"] + "_verification_failure_" + DataManager.VerifyErrors.Count); } } } else if (step.Name.Equals("Verify Training Set To Now") || step.Name.Equals("Verify Prediction Set To Now")) { if (step.Name.Equals("Verify Training Set To Now")) { xpath = "//input[@id='TrainingDataTimestamp']"; } else if (step.Name.Equals("Verify Prediction Set To Now")) { xpath = "//input[@id='PredictionDataTimestamp']"; } ele = driver.FindElement("xpath", xpath); data = ele.GetAttribute("value"); DateTime tDate = DateTime.Now; string toDate = tDate.ToString(); string dataSplit = data.Substring(0, 8); string toDateSplit = toDate.Substring(0, 8); if (dataSplit == toDateSplit) { log.Info("Verification Passed." + dataSplit + "matches" + toDateSplit); } else { log.Error("***Verification Failed." + dataSplit + "does not equal" + toDateSplit); err.CreateVerificationError(step, toDateSplit, dataSplit); 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; string data = ""; string xpath = ""; int count = 0; //List of necessary data List <string> activeTrainJobConfigIDArray = new List <string>(); List <string> inactiveTrainJobConfigIDArray = new List <string>(); List <string> activeTrainJobConfigTypeIDArray = new List <string>(); List <string> inactiveTrainJobConfigTypeIDArray = new List <string>(); List <string> activeJobSettingsArray = new List <string>(); List <string> inactiveJobSettingsArray = new List <string>(); List <string> activeTriggerTrainArray = new List <string>(); List <string> inactiveTriggerTrainArray = new List <string>(); List <string> activeTrainConfigIDArray = new List <string>(); List <string> inactiveTrainConfigIDArray = 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 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) { activeTrainJobConfigIDArray.Add(x["TrainingJobConfigurationID"].ToString()); } else { activeTrainJobConfigIDArray.Add(""); } //Active Name if (x["Name"] != null) { activeNameArray.Add(x["Name"].ToString()); } else { activeNameArray.Add(""); } //Active TrainingJobConfigurationTypeID if (x["TrainingJobConfigurationTypeID"] != null) { activeTrainJobConfigTypeIDArray.Add(x["TrainingJobConfigurationTypeID"].ToString()); } else { activeTrainJobConfigTypeIDArray.Add(""); } //Ative JobSettings if (x["JobSettings"] != null) { activeJobSettingsArray.Add(x["JobSettings"].ToString()); } else { activeJobSettingsArray.Add(""); } //Active TriggerTrainingJobConfigurationID if (x["TriggerTrainingJobConfigurationID"] != null) { activeTriggerTrainArray.Add(x["TriggerTrainingJobConfigurationID"].ToString()); } else { activeTriggerTrainArray.Add(""); } //Active TrainingConfigurationID if (x["TrainingConfigurationID"] != null) { activeTrainConfigIDArray.Add(x["TrainingConfigurationID"].ToString()); } else { activeTrainConfigIDArray.Add(""); } } } Dictionary <string, string[]> dataDictionary = new Dictionary <string, string[]>(); dataDictionary.Add("activeTrainJobConfigIDArray", activeTrainJobConfigIDArray.ToArray()); dataDictionary.Add("activeNameArray", activeNameArray.ToArray()); dataDictionary.Add("activeTrainJobConfigTypeIDArray", activeTrainJobConfigTypeIDArray.ToArray()); dataDictionary.Add("activeJobSettingsArray", activeJobSettingsArray.ToArray()); dataDictionary.Add("activeTriggerTrainArray", activeTriggerTrainArray.ToArray()); dataDictionary.Add("activeTrainConfigIDArray", activeTrainConfigIDArray.ToArray()); VerifyError err = new VerifyError(); ReadOnlyCollection <IWebElement> elements; if (step.Name.Equals("Check Training Job ID")) { string[] id = dataDictionary["activeTrainJobConfigIDArray"]; elements = driver.FindElements("xpath", "/html/body/div/main/div/div[2]/table/tbody/tr/td[1]"); if (elements.Count > 0) { for (int i = 0; i < elements.Count; i++) { if (elements[i].GetAttribute("innerText").Equals(id[i])) { log.Info("Match! " + "Expected: " + id[i] + " Actual: " + elements[i].GetAttribute("innerText")); } else { err.CreateVerificationError(step, "Expected Training Job ID: " + id[i], "Actual Training Job ID: " + elements[i].GetAttribute("innerText")); } } } else { log.Error("Can't find Training Job ID values"); } } else if (step.Name.Equals("Check Training Name")) { string[] id = dataDictionary["activeNameArray"]; elements = driver.FindElements("xpath", "/html/body/div/main/div/div[2]/table/tbody/tr/td[2]"); if (elements.Count > 0) { for (int i = 0; i < elements.Count; i++) { if (elements[i].GetAttribute("innerText").Equals(id[i])) { log.Info("Match! " + "Expected: " + id[i] + " Actual: " + elements[i].GetAttribute("innerText")); } else { err.CreateVerificationError(step, "Expected Training Job Name: " + id[i], "Actual Training Job Name: " + elements[i].GetAttribute("innerText")); } } } else { log.Error("Can't find Training Job Name values"); } } else if (step.Name.Equals("Check Training Configuration ID")) { string[] id = dataDictionary["activeTrainConfigIDArray"]; elements = driver.FindElements("xpath", "/html/body/div/main/div[4]/div[2]/span"); if (elements.Count > 0) { for (int i = 0; i < elements.Count; i++) { if (elements[i].GetAttribute("innerText").Equals(id[i])) { log.Info("Match! " + "Expected: " + id[i] + " Actual: " + elements[i].GetAttribute("innerText")); } else { err.CreateVerificationError(step, "Expected Training Config ID: " + id[i], "Actual Training Config ID: " + elements[i].GetAttribute("innerText")); } } } else { log.Error("Can't find Training Job Name values"); } } else if (step.Name.Equals("Check Trigger Training Job Config ID")) { string[] id = dataDictionary["activeTriggerTrainArray"]; for (int i = 0; i < id.Length; i++) { steps.Add(new TestStep(order, "Click Training Job with ID: " + dataDictionary["activeTrainJobConfigIDArray"][i], "", "click", "xpath", "/html/body/div/main/div/div[2]/table/tbody/tr/td[1][1][.='" + dataDictionary["activeTrainJobConfigIDArray"][i] + "']/a", wait)); TestRunner.RunTestSteps(driver, null, steps); steps.Clear(); elements = driver.FindElements("xpath", "/html/body/div/main/div/div[3]/div[5]/div/div[3]"); if (elements.Count > 0) { if (elements[i].GetAttribute("innerText").Equals(id[i])) { log.Info("Match! " + "Expected: " + id[i] + " Actual: " + elements[i].GetAttribute("innerText")); } else { err.CreateVerificationError(step, "Expected Trigger Training Job ID: " + id[i], "Actual Trigger Training Job ID: " + elements[i].GetAttribute("innerText")); } } else { log.Error("Can't find Trigger Training Job ID values"); } } } }
public void Execute(DriverManager driver, TestStep step) { long order = step.Order; string wait = step.Wait != null ? step.Wait : ""; IWebElement ele; int overlay; int size = 0; int channel = 0; int attempts = 10; string classList = ""; string title = ""; string edit = ""; string top = ""; bool topTitle = true; bool live = false; List <TestStep> steps = new List <TestStep>(); VerifyError err = new VerifyError(); if (step.Name.Equals("Verify Video is Playing")) { ele = driver.FindElement("xpath", "//div[@aria-label='Video Player']"); classList = ele.GetAttribute("className"); classList = classList.Substring(classList.IndexOf("jw-state-") + 9); classList = classList.Substring(0, classList.IndexOf(" ")); // state returns idle if overlay button is present overlay = driver.FindElements("xpath", "//div[@class='overlays']/div").Count; if (overlay > 1) { steps.Add(new TestStep(order, "Click Overlay Play Button", "", "click", "xpath", "//*[@class='overlay-play-button']", wait)); TestRunner.RunTestSteps(driver, null, steps); steps.Clear(); ele = driver.FindElement("xpath", "//div[@aria-label='Video Player']"); classList = ele.GetAttribute("className"); classList = classList.Substring(classList.IndexOf("jw-state-") + 9); classList = classList.Substring(0, classList.IndexOf(" ")); } // check video state. if not playing, wait and check again for 10 seconds do { log.Info("Video State: " + classList); if (!classList.Equals("playing")) { Thread.Sleep(1000); ele = driver.FindElement("xpath", "//div[@aria-label='Video Player']"); classList = ele.GetAttribute("className"); classList = classList.Substring(classList.IndexOf("jw-state-") + 9); classList = classList.Substring(0, classList.IndexOf(" ")); } }while (!classList.Equals("playing") && attempts-- > 0); if (classList.Equals("playing")) { log.Info("Verification PASSED. Video returned " + classList); } else { log.Error("***Verification FAILED. Video returned " + classList + " ***"); err.CreateVerificationError(step, "playing", classList); driver.TakeScreenshot(DataManager.CaptureMap["TEST_ID"] + "_verification_failure_" + DataManager.VerifyErrors.Count); } } else if (step.Name.Equals("Verify Video is Paused")) { ele = driver.FindElement("xpath", "//div[@aria-label='Video Player']"); classList = ele.GetAttribute("className"); classList = classList.Substring(classList.IndexOf("jw-state-") + 9); classList = classList.Substring(0, classList.IndexOf(" ")); do { log.Info("Video State: " + classList); }while (!classList.Equals("paused") && attempts-- > 0); if (classList.Equals("paused")) { log.Info("Verification PASSED. Video returned " + classList); } else { log.Error("***Verification FAILED. Video returned " + classList + " ***"); err.CreateVerificationError(step, "paused", classList); driver.TakeScreenshot(DataManager.CaptureMap["TEST_ID"] + "_verification_failure_" + DataManager.VerifyErrors.Count); } } else if (step.Name.Equals("Capture Number of Additional Channels")) { size = driver.FindElements("xpath", "//div[@class='live-tv-channels']//div[contains(@class,'item') or @class='live-tv-channel']").Count; // if size is zero, stream is attached to event. return and count if (size == 0) { log.Info("No Channels found. Stream is on event. Returning to Live TV."); steps.Add(new TestStep(order, "Return to Live TV", "", "click", "xpath", "//a[@href='/live']", wait)); TestRunner.RunTestSteps(driver, null, steps); steps.Clear(); size = driver.FindElements("xpath", "//div[@class='live-tv-channels']//div[contains(@class,'item') or @class='live-tv-channel']").Count; DataManager.CaptureMap["EVENT"] = "Y"; } DataManager.CaptureMap["CHANNELS"] = size.ToString(); } else if (step.Name.Equals("Select Additional Channels")) { if (DataManager.CaptureMap.ContainsKey("CHANNELS")) { size = Int32.Parse(DataManager.CaptureMap["CHANNELS"]); for (int i = 1; i <= size; i++) { steps.Add(new TestStep(order, "Run Template", "VerifyChannel", "run_template", "xpath", "", wait)); DataManager.CaptureMap["CURRENT_CHANNEL_NUM"] = i.ToString(); TestRunner.RunTestSteps(driver, null, steps); steps.Clear(); } } } else if (step.Name.Equals("Select Additional Channel")) { if (DataManager.CaptureMap.ContainsKey("CHANNELS")) { channel = Int32.Parse(DataManager.CaptureMap["CURRENT_CHANNEL_NUM"]); if (!driver.GetDriver().Url.Contains("live/")) { steps.Add(new TestStep(order, "Hover Channel " + channel, "", "click", "xpath", "//div[@class='live-tv-channel'][" + channel + "]//span", wait)); TestRunner.RunTestSteps(driver, null, steps); steps.Clear(); } steps.Add(new TestStep(order, "Select Channel " + channel, "", "click", "xpath", "(//div[contains(@class,'live-on-fox-secondary') or @class='live-tv-channel']//a[@class='pointer video'])[" + channel + "]", wait)); TestRunner.RunTestSteps(driver, null, steps); steps.Clear(); } } else if (step.Name.Equals("Check for Event")) { if (!driver.GetDriver().Url.Contains("live") || DataManager.CaptureMap.ContainsKey("EVENT")) { log.Info("At least one stream is on an event. Returning to Live TV for channels."); steps.Add(new TestStep(order, "Return to Live TV", "", "click", "xpath", "//a[@href='/live']", wait)); TestRunner.RunTestSteps(driver, null, steps); steps.Clear(); } } else if (step.Name.Equals("Click Live Play Button")) { // check if event overlay = driver.FindElements("xpath", "//div[contains(@class,'event has-stream')]").Count; if (overlay > 0) { // wait for one second, check for live play button Thread.Sleep(1000); overlay = driver.FindElements("xpath", "//div[contains(@class,'scroll-resize') or contains(@class,'live-tv-watch')]//div[@class='live-arrow']").Count; if (overlay > 0) { live = true; } } else { log.Info("Not an event. Live Play Button is present."); live = true; } if (live == true) { steps.Add(new TestStep(order, "Click Live Play Button", "", "click", "xpath", "//div[contains(@class,'scroll-resize') or contains(@class,'live-tv-watch')]//div[@class='live-arrow']", wait)); TestRunner.RunTestSteps(driver, null, steps); steps.Clear(); } } else if (step.Name.Equals("Verify Top Show Title")) { title = step.Data; top = "//div[contains(@class,'live-tv-main')]//div[contains(@class,'video-container')]//div[contains(@class,'video-title')]"; if (driver.FindElements("xpath", top).Count == 0) { topTitle = false; } if (!topTitle) { log.Info("Top Title not found. Checking for Promo..."); size = driver.FindElements("xpath", "//div[@class='promo-overlay']").Count; if (size > 0) { log.Info("Promo Found. No Top Title Expected."); } else { log.Error("***VERIFICATION FAILED. No Title or Promo Found ***"); err.CreateVerificationError(step, "Title or Promo", "NEITHER FOUND"); driver.TakeScreenshot(DataManager.CaptureMap["TEST_ID"] + "_verification_failure_" + DataManager.VerifyErrors.Count); } } else { if (title.Contains("...") && title.Length == 54) { edit = driver.FindElement("xpath", top).Text; edit = edit.Substring(0, 51) + "..."; log.Info("Title was shortened at 50 characters: " + edit); if (title.Equals(edit)) { log.Info("VERIFICATION PASSED. Shortened expected title [" + title + "] matches shortened actual title [" + edit + "]"); } else { log.Error("***VERIFICATION FAILED. Shortened expected title [" + title + "] DOES NOT match shortened actual title [" + edit + "]***"); err.CreateVerificationError(step, title, edit); driver.TakeScreenshot(DataManager.CaptureMap["TEST_ID"] + "_verification_failure_" + DataManager.VerifyErrors.Count); } } else { steps.Add(new TestStep(order, "Verify Top Show Title", title, "verify_value", "xpath", top, wait)); TestRunner.RunTestSteps(driver, null, steps); steps.Clear(); } } } else { throw new Exception("Test Step not found in script"); } }
/// <summary> /// Method to set null instance /// </summary> protected void SetNullInstance() { _driverManager = DriverManager.SetInstanceToNull(); Logger.Info("Setting browser instance to null", ""); }
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; List <string> odds = new List <string>(); 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 if (DataManager.CaptureMap["SPORT"].Equals("NHL")) { data = "PUCK 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("Verification 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 if (step.Name.Equals("Verify Dropdown Values")) { steps.Add(new TestStep(order, "Click Open Dropdown", "", "click", "xpath", "//div[contains(@class,'dropdown-header dropdown-open')]", wait)); TestRunner.RunTestSteps(driver, null, steps); steps.Clear(); elements = driver.FindElements("xpath", "//div[contains(@class,'dropdown-items')]//ul/li/a"); switch (step.Data) { case "MLB": odds = new List <string>() { "WORLD SERIES CHAMPION", "AMERICAN LEAGUE CHAMPION", "NATIONAL LEAGUE CHAMPION", "AL EAST CHAMPION", "AL CENTRAL CHAMPION", "AL WEST CHAMPION", "NL EAST CHAMPION", "NL CENTRAL CHAMPION", "NL WEST CHAMPION" }; break; default: log.Warn("No Step Data"); break; } if (elements.Count == odds.Count) { log.Info("Verification PASSED. Expected count [" + odds.Count + " matches Actual count [" + elements.Count + "]"); } else { log.Error("Verification FAILED. Expected count [" + odds.Count + " does not match Actual count [" + elements.Count + "]"); err.CreateVerificationError(step, odds.Count.ToString(), elements.Count.ToString()); driver.TakeScreenshot(DataManager.CaptureMap["TEST_ID"] + "_verification_failure_" + DataManager.VerifyErrors.Count); } foreach (IWebElement element in elements) { if (odds.Contains(element.GetAttribute("innerText"))) { log.Info("Verification PASSED. [" + element.GetAttribute("innerText") + " ] is expected."); } else { log.Error("Verification FAILED. [" + string.Join(",", odds) + "] does not contain Actual [" + element.GetAttribute("innerText") + "]"); err.CreateVerificationError(step, string.Join(",", odds), element.GetAttribute("innerText")); driver.TakeScreenshot(DataManager.CaptureMap["TEST_ID"] + "_verification_failure_" + DataManager.VerifyErrors.Count); } } } else { throw new Exception("Test Step not found in script"); } }
public IReadOnlyCollection <IWebElement> FindElements(By locator) { return(DriverManager.Instance().FindElements(locator)); }
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", "FEATURED", "DIVISION I", "NCAA TOURNAMENT", "A 10", "A-SUN", "AAC", "ACC", "AM. EAST", "BIG 12", "BIG EAST", "BIG SKY", "BIG SOUTH", "BIG TEN", "BIG WEST", "C-USA", "CAA", "DI-IND", "HORIZON", "IVY", "MAA", "MAC", "MEASTERN", "MVC", "MWC", "NEC", "OVC", "PAC-12", "PATRIOT", "SEC", "SLC", "SOUTHERN", "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") || step.Name.Equals("Verify WCBK Groups")) { // remove featured if (step.Name.Equals("Verify WCBK Groups")) { var list = new List <string>(cbkGroups); list.Remove("FEATURED"); cbkGroups = list.ToArray(); } 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", cbkGroups.Length.ToString(), "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 SignUpTest() { DriverManager.NavigateTo("https://www.facebook.com"); //When "extraInfo" is missing, the default value of "null" would make Locator return its text string valueString = Page.CurrentPage[FacebookLoginPage.ButtonByText.SignUp]; Assert.AreEqual(valueString, "Sign Up"); //To verify the Indexer can get the "class" attribute appeared within the button valueString = Page.CurrentPage[FacebookLoginPage.ButtonByText.SignUp, "class"]; Assert.AreEqual(valueString, "_6j mvm _6wk _6wl _58mi _3ma _6o _6v"); //Assure no exception is throw when querying a meaningless "extraInfo", // which would call IWebElement.GetAttribute() and returns null valueString = Page.CurrentPage[FacebookLoginPage.ButtonByText.SignUp, "non-existed"]; Assert.IsNull(valueString); valueString = Page.CurrentPage[FacebookLoginPage.ButtonByText.SignUp, "enabled"]; valueString = Page.CurrentPage[FacebookLoginPage.ButtonByText.SignUp, "displayed"]; valueString = Page.CurrentPage[FacebookLoginPage.ButtonByText.SignUp, "location"]; valueString = Page.CurrentPage[FacebookLoginPage.ButtonByText.SignUp, "size"]; valueString = Page.CurrentPage[FacebookLoginPage.ButtonByText.SignUp, "css"]; valueString = Page.CurrentPage[FacebookLoginPage.ButtonByText.SignUp, "parentcss"]; valueString = Page.CurrentPage[FacebookLoginPage.ButtonByText.SignUp, "fullcss"]; valueString = Page.CurrentPage[FacebookLoginPage.ButtonByText.SignUp, "style"]; //verify the name of the element is accessible valueString = Page.CurrentPage[FacebookLoginPage.TextByName.firstname, "name"]; Assert.AreEqual("firstname", valueString); //verify the Css selector is composed as expected valueString = Page.CurrentPage[FacebookLoginPage.TextByName.firstname, "css"]; Assert.IsTrue(valueString.Contains(@"input[type][name*='firstname']")); //verify the ParentCss() returns null when the Enum is defined directly in a page valueString = Page.CurrentPage[FacebookLoginPage.TextByName.firstname, "parentcss"]; Page.CurrentPage[FacebookLoginPage.TextByName.firstname] = "Jack"; //With extraInfo="sendkeys" to call IWebElement.SendKeys() via Indexer of the Locator class Page.CurrentPage[FacebookLoginPage.TextByName.firstname, "sendkeys"] = "Tom"; Thread.Sleep(500); Assert.AreEqual("JackTom", Page.CurrentPage[FacebookLoginPage.TextByName.firstname]); //Example to show how to use the locating mechanism to find the element and perform operation in traditional way Locator firstNameLocator = Page.CurrentPage.LocatorOf(FacebookLoginPage.TextByName.firstname); IWebElement firstNameElement = firstNameLocator.FindElement(); firstNameElement.Clear(); firstNameElement.SendKeys("Tom"); Page.CurrentPage[FacebookLoginPage.TextByName.lastname] = "Smith"; Page.CurrentPage[FacebookLoginPage.TextByName.regEmail] = "*****@*****.**"; Page.CurrentPage[FacebookLoginPage.TextByName.regEmailConfirmation] = "*****@*****.**"; Page.CurrentPage[FacebookLoginPage.TextByName.regPassword] = "Password#$@0"; //Default way to choose option: by entering first characters + TAB Page.CurrentPage[FacebookLoginPage.SelectById.month, "Ap"] = "true"; //Assert the SelectLocator returns text by default when "extraInfo" is missing Assert.AreEqual("Apr", Page.CurrentPage[FacebookLoginPage.SelectById.month]); //Assert SelectLocator returns index value as its order, even when it is not defined in the web page Assert.AreEqual("4", Page.CurrentPage[FacebookLoginPage.SelectById.month, "#"]); //Assert the value of the selected item Assert.AreEqual("4", Page.CurrentPage[FacebookLoginPage.SelectById.month, "$"]); //Select "day" by text of the option, with "text=" to specify it must be matched exactly Page.CurrentPage[FacebookLoginPage.SelectById.day, "text=15"] = "true"; Assert.AreEqual(Page.CurrentPage[FacebookLoginPage.SelectById.day, "text"], "15"); //Select "year" by actually input "201" + TAB, thus the first one "2014" shall be selected Page.CurrentPage[FacebookLoginPage.SelectById.year, "201"] = "no matter what"; //Confirm it goes as expected Assert.AreEqual(Page.CurrentPage[FacebookLoginPage.SelectById.year], "2014"); //Select "day" with "index", because the element has no "index" attribute, so the nature order is used actually Page.CurrentPage[FacebookLoginPage.SelectById.day, "Index=8"] = "true"; Assert.AreEqual(Page.CurrentPage[FacebookLoginPage.SelectById.day, "$"], "8"); //Select "day" by "value" and validate the result Page.CurrentPage[FacebookLoginPage.SelectById.day, "$24"] = "true"; Assert.AreEqual(Page.CurrentPage[FacebookLoginPage.SelectById.day, ""], "24"); //Choose radio by clicking associated lable Page.CurrentPage[FacebookLoginPage.LabelByText.Female] = "true"; Assert.AreEqual(true.ToString(), Page.CurrentPage[FacebookLoginPage.RadioByCustom.female, "selected"]); Assert.AreEqual(false.ToString(), Page.CurrentPage[FacebookLoginPage.RadioByCustom.male]); //Choose radio directly Page.CurrentPage[FacebookLoginPage.LabelByText.Male] = "true"; Assert.AreEqual(true.ToString(), Page.CurrentPage[FacebookLoginPage.RadioByCustom.male, ""]); //Click the sign-up button //Page.CurrentPage[FacebookLoginPage.ButtonByText.SignUp] = "true"; Page.CurrentPage[FacebookLoginPage.ButtonByText.SignUp] = "submit"; }
public static void ConditionIsMet(Func <IWebDriver, bool> action, int timeOut = 10) { var wait = new WebDriverWait(DriverManager.GetDriver(), TimeSpan.FromSeconds(timeOut)); wait.Until(action); }
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 total = 0; string day = ""; string games = ""; string status = ""; string date = ""; if (step.Name.Equals("Verify Event")) { if (DataManager.CaptureMap.ContainsKey("IN_SEASON")) { DataManager.CaptureMap["GAME"] = step.Data; //get date for scores id if (DataManager.CaptureMap["SPORT"].Equals("TOP")) { date = driver.FindElement("xpath", "//div[contains(@class,'scores-date')]//div[contains(@class,'sm')]").GetAttribute("innerText"); } else { date = driver.FindElement("xpath", "//div[contains(@class,'scores-app-root')]/div[not(@style='display: none;')]//div[contains(@class,'week-selector')]//button/span[contains(@class,'title')]").GetAttribute("innerText"); } log.Info("Current segment: " + date); if (date.Equals("YESTERDAY")) { date = DateTime.Today.AddDays(-1).ToString("yyyyMMdd"); log.Info(date); } else if (date.Equals("TODAY")) { date = DateTime.Today.ToString("yyyyMMdd"); log.Info(date); } else if (date.Equals("TOMORROW")) { date = DateTime.Today.AddDays(+1).ToString("yyyyMMdd"); log.Info(date); } else { date = DateTime.Parse(date).ToString("MMdd"); log.Info(date); } ele = driver.FindElement("xpath", "//div[@class='scores' and contains (@id,'" + date + "')]//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", "//div[@class='scores' and contains (@id,'" + date + "')]//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 if (step.Name.Equals("Verify Events in Segment")) { DataManager.CaptureMap["SPORT"] = step.Data; //get date for scores id if (DataManager.CaptureMap["SPORT"].Equals("TOP")) { date = driver.FindElement("xpath", "//div[contains(@class,'scores-date')]//div[contains(@class,'sm')]").GetAttribute("innerText"); } else { date = driver.FindElement("xpath", "//div[contains(@class,'scores-app-root')]/div[not(@style='display: none;')]//div[contains(@class,'week-selector')]//button/span[contains(@class,'title')]").GetAttribute("innerText"); } log.Info("Current segment: " + date); if (date.Equals("YESTERDAY")) { date = DateTime.Today.AddDays(-1).ToString("yyyyMMdd"); log.Info(date); day = "TeamSport_ScoresYesterday"; } else if (date.Equals("TODAY")) { date = DateTime.Today.ToString("yyyyMMdd"); log.Info(date); day = "TeamSport_ScoresToday"; } else if (date.Equals("TOMORROW")) { date = DateTime.Today.AddDays(+1).ToString("yyyyMMdd"); log.Info(date); day = "TeamSport_ScoresTomorrow"; } else { date = DateTime.Parse(date).ToString("MMdd"); log.Info(date); day = "TeamSport_ScoresFuture"; } total = driver.FindElements("xpath", "//div[@class='scores' and contains (@id,'" + date + "')]//a[contains(@class,'score-chip')]").Count; for (int game = 1; game <= total; game++) { DataManager.CaptureMap["GAME"] = game.ToString(); ele = driver.FindElement("xpath", "//div[@class='scores' and contains (@id,'" + date + "')]//a[contains(@class,'score-chip')][" + game + "]"); 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", "//div[@class='scores' and contains (@id,'" + date + "')]//a[contains(@class,'score-chip')][" + game + "]//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"; } } steps.Add(new TestStep(order, "Run Event Template", step.Data, "run_template", "xpath", "", wait)); TestRunner.RunTestSteps(driver, null, steps); steps.Clear(); steps.Add(new TestStep(order, "Return to Scores Segment", day, "run_template", "xpath", "", wait)); TestRunner.RunTestSteps(driver, null, steps); steps.Clear(); } } else { throw new Exception("Test Step not found in script"); } }
public static void KillAnyLocalProcesses() { DriverManager.KillAnyLocalDriverProcesses(); }
public BasePage() { PageFactory.InitElements(DriverManager.GetInstance().GetWebDriver(), this); }
public string getTitle() { return(DriverManager.GetInstance().GetWebDriver().Title); }
public IWebElement FindElement(By locator) { return(DriverManager.Instance().FindElement(locator)); }
public SmokeTests(Type driverType) { this._driverType = driverType; driverManager = new DriverManager(this._driverType); }
public bool IsDisplayed(By locator, int timeout = 30) { var wait = new WebDriverWait(DriverManager.Instance(), TimeSpan.FromSeconds(timeout)); return(wait.Until(d => DriverManager.Instance().FindElement(locator).Displayed)); }
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') or contains(@class,'week-selector')]//*[contains(@class,'sm-14')]"; 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 NCAAW 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 "NCAAW BK": xpath = "//div[contains(@class,'desktop')]//a[not(contains(@class,'more-button')) and contains(.,'NCAAW 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"); } }
/// <summary> /// Constructor for generic base page /// </summary> public GenericBasePage() { _driverManager = DriverManager.GetInstance(); _driver = _driverManager.GetDriver(); _wait = _driverManager.GetWait(); }
public HomePage(DriverManager manager) : base(manager) { Header = new Headers(manager); Table = new Tables(manager); NavigationBar = new NavigationBar(manager); }
public void Test() { DriverManager.GetDriver <IWebDriver>() .Navigate() .GoToUrl("https://demoqa.com"); }
public ShapeRoomWCServices(DriverManager manager) : base(manager) { }
public override void RunCommand(RasterCommand command) { switch (command) { case RasterCommand.OpenFolder: string filename = Model.Filename; if (!string.IsNullOrWhiteSpace(filename)) { PathHelper.OpenFolderWithExplorer(filename); } else { MessageService.Current.Info("Can't find the datasource."); } break; case RasterCommand.ProjectionDetails: _context.ShowProjectionProperties(Model.Projection, View as IWin32Window); break; case RasterCommand.ClearColorAdjustments: View.ClearColorAdjustments(); break; case RasterCommand.Apply: Apply(); break; case RasterCommand.RemoveStyle: LayerSerializationHelper.RemoveSettings(Model, false); break; case RasterCommand.LoadStyle: { bool result = LayerSerializationHelper.LoadSettings(Model, _broadcaster, false); if (result) { View.Initialize(); Apply(); } MessageService.Current.Info(result ? "Layer options are loaded." : "Failed to load layer options."); } break; case RasterCommand.SaveStyle: LayerSerializationHelper.SaveSettings(Model); break; case RasterCommand.ShowDriverInfo: if (_raster == null) { return; } var manager = new DriverManager { SelectedDriver = _raster.Driver }; _context.Container.Run <DriversPresenter, DriverManager>(manager); break; default: throw new ArgumentOutOfRangeException("command"); } }
public PageDroppable(DriverManager driverManager) : base(driverManager) { PageUrl = "/droppable"; }
public void Execute(DriverManager driver, TestStep step) { long order = step.Order; string wait = step.Wait != null ? step.Wait : ""; int super6Count = 0; int idInList = 0; List <TestStep> steps = new List <TestStep>(); VerifyError err = new VerifyError(); IJavaScriptExecutor js = (IJavaScriptExecutor)driver.GetDriver(); var path = Path.Combine(Directory.GetCurrentDirectory()); path = Path.Combine(path, "SeleniumProject/Postman_Collection/report.json"); //var path = Path.Combine(@"C:\Users\truon\source\repos\New_Selenium.hao\SeleniumProject\Postman_Collection\report.json"); log.Info("Current Directory: " + path); var list = JObject.Parse(File.ReadAllText(path)); DateTime dt = new DateTime(); foreach (JToken x in list["list"]) { if (x["league"].ToString() == DataManager.CaptureMap["SPORT"]) { if (DataManager.CaptureMap["SPORT"] == "CFB") { 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", "//div[contains(@class,'scores-home-container')]//div[contains(@class,'dropdown-root active')]//ul", wait)); steps.Add(new TestStep(order, "Click on FBS (I - A)", "", "click", "xpath", "//div[@class='sub-container dropdown-items-container']//a[contains(text(), 'FBS (I-A)')]", wait)); TestRunner.RunTestSteps(driver, null, steps); steps.Clear(); } foreach (string id in x["ids"]) { if (step.Name.Equals("Verify Super6 Scorechips")) { if ((int)dt.DayOfWeek > 0 && (int)dt.DayOfWeek < 4) { Thread.Sleep(2000); js.ExecuteScript("window.scrollTo(0, document.body.scrollHeight)"); } idInList++; ReadOnlyCollection <IWebElement> elements; log.Info(DataManager.CaptureMap["SPORT"] + " game id:" + id); log.Info("Checking scorechip"); elements = driver.FindElements("xpath", "//a[contains(@href,'id=" + id + "')]//div[@class='super-six-logo']"); if (elements.Count > 0) { js.ExecuteScript("arguments[0].scrollIntoView(false)", driver.FindElement("xpath", "//a[contains(@href,'id=" + id + "')]")); log.Info("Found scorechip with super6 logo"); super6Count++; } else { elements = driver.FindElements("xpath", "//a[contains(@href,'id=" + id + "')]"); if (elements.Count > 0) { js.ExecuteScript("arguments[0].scrollIntoView(false)", driver.FindElement("xpath", "//a[contains(@href,'id=" + id + "')]")); log.Error("Error: Cannot find super6 logo on scorechip(id=" + id.ToString() + ")"); err.CreateVerificationError(step, "Super6 logo expected for ID: " + id.ToString(), "Super6 logo not found"); driver.TakeScreenshot(DataManager.CaptureMap["TEST_ID"] + "_verification_failure_" + DataManager.VerifyErrors.Count); } else { log.Error("Error: Cannot find scorechip(id=" + id.ToString() + ")"); err.CreateVerificationError(step, "Expected scorechip for ID: " + id.ToString(), "No scorechip for ID: " + id.ToString() + " found"); driver.TakeScreenshot(DataManager.CaptureMap["TEST_ID"] + "_verification_failure_" + DataManager.VerifyErrors.Count); } } } else if (step.Name.Equals("Verify Super6 on Event Page")) { ReadOnlyCollection <IWebElement> elements; if (DataManager.CaptureMap["SPORT"] == "NFL") { steps.Add(new TestStep(order, "Click Scores", "", "click", "xpath", "//a[@href='/scores']", wait)); steps.Add(new TestStep(order, "Click NFL", "", "click", "xpath", "//div[contains(@class,'desktop')]//a[not(contains(@class,'more-button')) and contains(.,'NFL')]", wait)); } else if (DataManager.CaptureMap["SPORT"] == "CFB") { steps.Add(new TestStep(order, "Click Scores", "", "click", "xpath", "//a[@href='/scores']", wait)); steps.Add(new TestStep(order, "Click NCAA FB", "", "click", "xpath", "//div[contains(@class,'desktop')]//a[not(contains(@class,'more-button')) and contains(.,'NCAA FB')]", wait)); 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", "//div[contains(@class,'scores-home-container')]//div[contains(@class,'dropdown-root active')]//ul", wait)); steps.Add(new TestStep(order, "Click on FBS (I - A)", "", "click", "xpath", "//div[@class='sub-container dropdown-items-container']//a[contains(text(), 'FBS (I-A)')]", wait)); } else if (DataManager.CaptureMap["SPORT"] == "NBA") { steps.Add(new TestStep(order, "Click Scores", "", "click", "xpath", "//a[@href='/scores']", wait)); steps.Add(new TestStep(order, "Click NFL", "", "click", "xpath", "//div[contains(@class,'desktop')]//a[not(contains(@class,'more-button')) and contains(.,'NBA')]", wait)); } TestRunner.RunTestSteps(driver, null, steps); steps.Clear(); if ((int)dt.DayOfWeek > 0 && (int)dt.DayOfWeek < 4) { Thread.Sleep(2000); js.ExecuteScript("window.scrollTo(0, document.body.scrollHeight)"); } //Getting abbreviation log.Info("Getting team abbreviation"); js.ExecuteScript("arguments[0].scrollIntoView(false)", driver.FindElement("xpath", "//a[contains(@href,'id=" + id + "')]")); steps.Add(new TestStep(order, "Capture Team from " + step.Data, "FIRST_ABB", "capture", "xpath", "(//a[contains(@href,'id=" + id + "')]//div[contains(@class,'abbreviation')]//span)[1]", wait)); steps.Add(new TestStep(order, "Capture Team from " + step.Data, "SECOND_ABB", "capture", "xpath", "(//a[contains(@href,'id=" + id + "')]//div[contains(@class,'abbreviation')]//span)[2]", wait)); steps.Add(new TestStep(order, "Click Scorechip with ID: " + id.ToString(), "", "click", "xpath", "//a[contains(@href,'id=" + id + "')]", wait)); TestRunner.RunTestSteps(driver, null, steps); steps.Clear(); log.Info("Check for Super6 content"); js.ExecuteScript("window.scrollBy({top: 100,left: 0,behavior: 'smooth'});"); elements = driver.FindElements("xpath", "//div[contains(@class,'feed-component super-six-component')]"); if (elements.Count > 0) { log.Info("Found Super6 Component"); js.ExecuteScript("arguments[0].scrollIntoView(false)", driver.FindElement("xpath", "//div[contains(@class,'feed-component super-six-component')]")); log.Info("Checking for Super6 logo"); elements = driver.FindElements("xpath", "//div[contains(@class,'feed-component super-six-component')]/div[contains(@class,'super-six-logo')]"); //Super6 Logo if (elements.Count > 0) { log.Info("Found Super6 logo"); } else { log.Error("Cannot find Super6 Logo"); err.CreateVerificationError(step, "Expected Super6 logo on event page for ID: " + id.ToString(), "No Super6 logo is found"); driver.TakeScreenshot(DataManager.CaptureMap["TEST_ID"] + "_verification_failure_" + DataManager.VerifyErrors.Count); } log.Info("Checking for Super6 Header"); //Super6 Header elements = driver.FindElements("xpath", "//div[contains(@class,'feed-component super-six-component')]/div[contains(@class,'super-six-header')]"); if ((elements.Count > 0) && ((elements.ElementAt(0).GetAttribute("innerText")).Equals("THIS IS A SUPER 6 GAME"))) { log.Info("Found Super6 header"); } else { log.Error("Cannot find Super6 Header"); err.CreateVerificationError(step, "Expected Super6 header on event page for ID: " + id.ToString(), "No Super6 header is found"); driver.TakeScreenshot(DataManager.CaptureMap["TEST_ID"] + "_verification_failure_" + DataManager.VerifyErrors.Count); } log.Info("Checking for Super6 Content"); //Super6 Content elements = driver.FindElements("xpath", "//div[contains(@class,'feed-component super-six-component')]/div[contains(@class,'super-six-content')]"); if (elements.Count > 0) { log.Info("Found Super6 Content"); } else { log.Error("Cannot find Super6 Content"); err.CreateVerificationError(step, "Expected Super6 Content on event page for ID: " + id.ToString(), "No Super6 Content is found"); driver.TakeScreenshot(DataManager.CaptureMap["TEST_ID"] + "_verification_failure_" + DataManager.VerifyErrors.Count); } log.Info("Checking for Super6 Chart"); //Super6 Chart elements = driver.FindElements("xpath", "//div[contains(@class,'feed-component super-six-component')]/div[contains(@class,'vote-chart-container')]"); if (elements.Count > 0) { log.Info("Found Super6 Chart"); elements = driver.FindElements("xpath", "//div[contains(@class,'feed-component super-six-component')]/div[contains(@class,'vote-chart-container')]//div[contains(@class,'chart-label uc')]"); log.Info("Checking for team abbreviations"); if (DataManager.CaptureMap["FIRST_ABB"] == elements.ElementAt(0).GetAttribute("innerText") && DataManager.CaptureMap["SECOND_ABB"] == elements.ElementAt(1).GetAttribute("innerText")) { log.Info("Team Abbreviations Matched"); } else { log.Error("Team Abbrevations Not Matched"); err.CreateVerificationError(step, "Expected Matching Team Abbreviations", "Team Abbrevations are not Matched"); err.CreateVerificationError(step, "Expected first abbrevation " + DataManager.CaptureMap["FIRST_ABB"], "Actual first abbrevation " + elements.ElementAt(0).GetAttribute("innerText")); err.CreateVerificationError(step, "Expected second abbrevation " + DataManager.CaptureMap["SECOND_ABB"], "Actual second abbrevation " + elements.ElementAt(1).GetAttribute("innerText")); driver.TakeScreenshot(DataManager.CaptureMap["TEST_ID"] + "_verification_failure_" + DataManager.VerifyErrors.Count); } } else { log.Error("Cannot find Super6 Chart"); err.CreateVerificationError(step, "Expected Super6 Chart on event page for ID: " + id.ToString(), "No Super6 Chart is found"); driver.TakeScreenshot(DataManager.CaptureMap["TEST_ID"] + "_verification_failure_" + DataManager.VerifyErrors.Count); } } else { log.Error("Cannot find Super6 Component"); err.CreateVerificationError(step, "Expected Super6 Component on event page for ID: " + id.ToString(), "No Super6 Component is found"); driver.TakeScreenshot(DataManager.CaptureMap["TEST_ID"] + "_verification_failure_" + DataManager.VerifyErrors.Count); } } } } } if (step.Name.Equals("Verify Super6 Scorechips")) { if (idInList == super6Count) { if (super6Count == 0) { log.Info("No super6 id coming from SD"); } else { log.Info("Found all super6 events for this week"); } } else { log.Error("Missing super6 logo on " + (idInList - super6Count).ToString() + " event(s)"); } } }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: public static void mergeProjectsInOneDatabase(nomitech.common.ui.UIProgress paramUIProgress, String paramString1, String paramString2, String paramString3, nomitech.common.db.local.ProjectDbmsTable paramProjectDbmsTable, String paramString4, String paramString5, java.util.Set<String> paramSet, boolean paramBoolean1, boolean paramBoolean2) throws Exception public static void mergeProjectsInOneDatabase(UIProgress paramUIProgress, string paramString1, string paramString2, string paramString3, ProjectDbmsTable paramProjectDbmsTable, string paramString4, string paramString5, ISet <string> paramSet, bool paramBoolean1, bool paramBoolean2) { ProjectDBUtil.initDriver(ProjectDBUtil.SQLSERVER_DBMS); ProjectDBDataMover projectDBDataMover; (projectDBDataMover = new ProjectDBDataMover(paramUIProgress)).setProgress(paramUIProgress, "Connecting to master database " + paramString1 + " port " + paramString2 + "..."); string str = ProjectDBUtil.createJdbcUrl(paramString1, paramString3, paramString2, ProjectDBUtil.SQLSERVER_DBMS); Connection connection1 = DriverManager.getConnection(str + ";useLOBs=false", paramString4, paramString5); connection1.AutoCommit = false; setProgress(paramUIProgress, "Connecting to project database " + paramString1 + " port " + paramString2 + "..."); str = ProjectDBUtil.createJdbcUrl(paramProjectDbmsTable.HostName, paramProjectDbmsTable.DatabaseName, paramProjectDbmsTable.HostPort, ProjectDBUtil.SQLSERVER_DBMS); Connection connection2 = projectDBDataMover.loginDatabase(str + ";useLOBs=false", paramString4, paramString5); connection2.AutoCommit = false; setProgress(paramUIProgress, "Loading databases from master..."); System.Collections.IList list = projectDBDataMover.getAllProjectUrls(connection1, paramSet, false); ProjectUrlTable projectUrlTable = new ProjectUrlTable(); projectUrlTable.Dbms = Convert.ToInt32(ProjectDBUtil.SQLSERVER_DBMS); projectUrlTable.DatabaseName = paramProjectDbmsTable.DatabaseName; projectUrlTable.Hostname = paramProjectDbmsTable.HostName; projectUrlTable.Port = paramProjectDbmsTable.HostPort; projectUrlTable.DbmsName = paramProjectDbmsTable.InstanceName; projectUrlTable.CreatesNewDatabases = Convert.ToBoolean(false); projectUrlTable.Username = paramProjectDbmsTable.HostUsername; projectUrlTable.Password = paramProjectDbmsTable.HostPassword; projectUrlTable.Url = str; setProgress(paramUIProgress, "Processing " + list.Count + " databases..."); System.Collections.ICollection collection = projectDBDataMover.filterOutUrlsAlreadyInTarget(connection2, list); connection2.close(); setProgress(paramUIProgress, "Target Database is " + projectUrlTable.DatabaseName + " and " + collection.Count + " will be processed..."); foreach (ProjectUrlTable projectUrlTable1 in collection) { if (projectUrlTable1.DatabaseName.Equals(projectUrlTable.DatabaseName, StringComparison.OrdinalIgnoreCase)) { continue; } projectUrlTable.ProjectUrlId = projectUrlTable1.ProjectUrlId; setProgress(paramUIProgress, "\nMerging Database: " + projectUrlTable1.DatabaseName + ", Project ID: " + projectUrlTable1.Id + ", Name: " + projectUrlTable1.Name + " ..."); try { if (projectUrlTable1.Dbms == projectUrlTable.Dbms && projectUrlTable1.Hostname.Equals(projectUrlTable.Hostname)) { projectDBDataMover.initialize(projectUrlTable1, projectUrlTable); projectDBDataMover.moveDataSameInstance(); } else { projectDBDataMover.initialize(projectUrlTable1, projectUrlTable); projectDBDataMover.moveDataNotSameInstance(); } projectDBDataMover.executeUpdateQuery(connection1, "UPDATE PROJECTURL SET DBSINGLE=0, DBNAME= '" + projectUrlTable.DatabaseName + "', DBSRV = " + projectUrlTable.Dbms + ", DBSRVNAME= '" + projectUrlTable.DbmsName + "', DBUSR= '******', DBPSWD= '" + projectUrlTable.Password + "', URL = '" + projectUrlTable.Url + "' WHERE PROJECTURLID=" + projectUrlTable.ProjectUrlId); setProgress(paramUIProgress, "Done"); } catch (Exception exception) { Console.WriteLine("Could not merge " + projectUrlTable1.DatabaseName + " to " + projectUrlTable.DatabaseName); Console.WriteLine(exception.ToString()); Console.Write(exception.StackTrace); } if (paramBoolean2 && projectUrlTable1.Dbms.Value == ProjectDBUtil.SQLSERVER_DBMS) { try { setProgress(paramUIProgress, "Dropping " + projectUrlTable1.DatabaseName + " ..."); projectDBDataMover.executeUpdateQuery(connection1, "DROP DATABASE [" + projectUrlTable1.DatabaseName + "]"); setProgress(paramUIProgress, "Done"); } catch (Exception) { Console.WriteLine("Could not drop " + projectUrlTable1.DatabaseName); } } } connection1.close(); }
public void ShowAlert() { DriverManager.GetJsExecutor().ExecuteScript("alert('Hello!I am an alert box!!');"); }
//private DriverManager Manager; public Room3DWCServices(DriverManager manager) : base(manager) { }
public void ScroolToClick(string text) { DriverManager.GetDriver <AppiumDriver <AppiumWebElement> >().ScrollToExact(text).Click(); }
public PageStudentRegistrationForm(DriverManager driverManager) : base(driverManager) { PageUrl = "/automation-practice-form"; }