Ejemplo n.º 1
0
        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());
                }
            }
        }
Ejemplo n.º 2
0
        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");
            }
        }
Ejemplo n.º 3
0
        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");
            }
        }
Ejemplo n.º 4
0
        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");
            }
        }
Ejemplo n.º 5
0
        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");
            }
        }
Ejemplo n.º 6
0
        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");
            }
        }
Ejemplo n.º 7
0
        public void Execute(DriverManager driver, TestStep step)
        {
            VerifyError     err    = new VerifyError();
            long            order  = step.Order;
            Random          random = new Random();
            string          wait   = step.Wait != null ? step.Wait : "";
            string          sport  = step.Data;
            string          activeTeam;
            int             total        = 0;
            int             size         = 0;
            string          explore      = "";
            bool            shown        = false;
            string          teamSelector = "";
            List <TestStep> steps        = new List <TestStep>();

            if (step.Name.Equals("Verify Teams by Sport"))
            {
                steps.Add(new TestStep(order, "Click Sport Menu Open", "", "click", "xpath", "//div[contains(@id,'App') and not(contains(@style,'none'))]//a[contains(@class,'entity-list')][div[div[contains(.,'" + sport + "')]]]", wait));
                TestRunner.RunTestSteps(driver, null, steps);
                steps.Clear();

                var teams = driver.FindElements("xpath", "//div[contains(@class,'explore-basic-rows')]//a");
                for (int i = 0; i < teams.Count; i++)
                {
                    int counter = i + 1;
                    activeTeam = driver.FindElement("xpath", "(//div[contains(@class,'explore-basic-rows')]//a)[" + counter + "]").GetAttribute("innerText");

                    if (activeTeam.Equals("NFL"))
                    {
                        activeTeam = "NATIONAL FOOTBALL LEAGUE";
                    }

                    steps.Add(new TestStep(order, "Click Team Name", "", "click", "xpath", "(//div[contains(@class,'explore-basic-rows')]//a)[" + counter + "]", wait));
                    steps.Add(new TestStep(order, "Verify Team Name in Header", activeTeam.ToUpper(), "verify_value", "xpath", "//div[contains(@class,'entity-header')]//div[contains(@class,'entity-title')]//span", wait));
                    TestRunner.RunTestSteps(driver, null, steps);
                    steps.Clear();

                    if (i < teams.Count - 1)
                    {
                        steps.Add(new TestStep(order, "Click Explore", "", "click", "xpath", "//a[contains(@class,'explore-link')]", wait));
                        steps.Add(new TestStep(order, "Click Sport Menu Open", "", "click", "xpath", "//div[contains(@id,'App') and not(contains(@style,'none'))]//a[contains(@class,'entity-list')][div[div[contains(.,'" + sport + "')]]]", wait));
                        TestRunner.RunTestSteps(driver, null, steps);
                        steps.Clear();
                    }
                }
            }

            else if (step.Name.Equals("Verify MLB Teams"))
            {
                total = driver.FindElements(
                    "xpath", "//div[@id='exploreApp']//div[contains(@class,'explore-basic-rows')]//a[not(contains(@class,'header'))]").Count;
                for (int t = 1; t <= total; t++)
                {
                    DataManager.CaptureMap["MLB_TEAM"] = driver.FindElement("xpath", "//div[@id='exploreApp']//div[contains(@class,'explore-basic-rows')]//a[not(contains(@class,'header'))][" + t + "]").Text.ToUpper();
                    steps.Add(new TestStep(order, "Click Team " + t, "", "click", "xpath", "//div[@id='exploreApp']//div[contains(@class,'explore-basic-rows')]//a[not(contains(@class,'header'))][" + t + "]", wait));
                    steps.Add(new TestStep(order, "Template for Team " + t, "", "run_template", "xpath", "MLB_Team", wait));
                    TestRunner.RunTestSteps(driver, null, steps);
                    steps.Clear();
                }
            }

            else if (step.Name.Equals("Verify NBA Teams"))
            {
                total = driver.FindElements(
                    "xpath", "//div[@id='exploreApp']//div[contains(@class,'explore-basic-rows')]//a[not(contains(@class,'header'))]").Count;
                for (int t = 1; t <= total; t++)
                {
                    DataManager.CaptureMap["NBA_TEAM"] = driver.FindElement("xpath", "//div[@id='exploreApp']//div[contains(@class,'explore-basic-rows')]//a[not(contains(@class,'header'))][" + t + "]").Text.ToUpper();
                    steps.Add(new TestStep(order, "Click Team " + t, "", "click", "xpath", "//div[@id='exploreApp']//div[contains(@class,'explore-basic-rows')]//a[not(contains(@class,'header'))][" + t + "]", wait));
                    steps.Add(new TestStep(order, "Template for Team " + t, "", "run_template", "xpath", "NBA_Team", wait));
                    TestRunner.RunTestSteps(driver, null, steps);
                    steps.Clear();
                }
            }

            else if (step.Name.Equals("Click Entity by Data"))
            {
                steps.Add(new TestStep(order, "Click " + step.Data, "", "click", "xpath", "//div[contains(@id,'App') and not(contains(@style,'none'))]//a[contains(@class,'entity-list-row-container')][div[contains(.,'" + step.Data + "')]]", wait));
                TestRunner.RunTestSteps(driver, null, steps);
                steps.Clear();
            }

            else if (step.Name.Contains("Capture") && step.Name.Contains("Random Conference"))
            {
                teamSelector = "//div[contains(@id,'App') and not(contains(@style,'none'))]//a[contains(@class,'entity-list-row-container') and not(contains(@class,'header'))]";
                total        = driver.FindElements("xpath", teamSelector).Count;
                total        = random.Next(1, total + 1);
                steps.Add(new TestStep(order, "Capture Randomized Conference", "RANDOM_CONF", "capture", "xpath", "(" + teamSelector + ")[" + total + "]", wait));
                // click as well
                if (step.Name.Contains("Click"))
                {
                    steps.Add(new TestStep(order, "Click Randomized Conference", "", "click", "xpath", "(" + teamSelector + ")[" + total + "]", wait));
                }
                TestRunner.RunTestSteps(driver, null, steps);
                steps.Clear();
                DataManager.CaptureMap["RANDOM_CONF_UP"] = DataManager.CaptureMap["RANDOM_CONF"].ToUpper();
            }

            else if (step.Name.Contains("Capture") && step.Name.Contains("Random Team"))
            {
                teamSelector = "//div[contains(@id,'App') and not(contains(@style,'none'))]//a[@class='entity-list-row-container']";
                total        = driver.FindElements("xpath", teamSelector).Count;
                total        = random.Next(1, total + 1);
                steps.Add(new TestStep(order, "Capture Randomized Team", "RANDOM_TEAM", "capture", "xpath", "(" + teamSelector + ")[" + total + "]", wait));
                // click as well
                if (step.Name.Contains("Click"))
                {
                    steps.Add(new TestStep(order, "Click Randomized Team", "", "click", "xpath", "(" + teamSelector + ")[" + total + "]", wait));
                }
                TestRunner.RunTestSteps(driver, null, steps);
                steps.Clear();
                DataManager.CaptureMap["RANDOM_TEAM_UP"] = DataManager.CaptureMap["RANDOM_TEAM"].ToUpper();
            }

            else if (step.Name.Contains("Capture") && step.Name.Contains("Random Player"))
            {
                teamSelector = "//div[contains(@id,'App') and not(contains(@style,'none'))]//a[@class='entity-list-row-container']";
                total        = driver.FindElements("xpath", teamSelector).Count;
                total        = random.Next(1, total + 1);
                steps.Add(new TestStep(order, "Capture Randomized Player", "RANDOM_PLAYER", "capture", "xpath", "(" + teamSelector + ")[" + total + "]", wait));
                // click as well
                if (step.Name.Contains("Click"))
                {
                    steps.Add(new TestStep(order, "Click Randomized Player", "", "click", "xpath", "(" + teamSelector + ")[" + total + "]", wait));
                }
                TestRunner.RunTestSteps(driver, null, steps);
                steps.Clear();
                DataManager.CaptureMap["RANDOM_PLAYER_UP"] = DataManager.CaptureMap["RANDOM_PLAYER"].ToUpper();
            }

            else if (step.Name.Equals("Click Explore"))
            {
                while (!shown && size++ < 3)
                {
                    explore = "//a[contains(@class,'explore-link')]";
                    steps.Add(new TestStep(order, "Click Explore", "", "click", "xpath", explore, wait));
                    TestRunner.RunTestSteps(driver, null, steps);
                    steps.Clear();
                    explore = driver.FindElement("xpath", "//div[@id='ssrExploreApp']").GetAttribute("style");
                    log.Info("Style: " + explore);
                    if (explore.Equals("display: none;"))
                    {
                        shown = false;
                    }
                    else
                    {
                        shown = true;
                    }
                    Thread.Sleep(0500);
                }
            }

            else
            {
                throw new Exception("Test Step not found in script");
            }
        }
Ejemplo n.º 8
0
        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();
            }
        }
Ejemplo n.º 9
0
        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...");
            }
        }
Ejemplo n.º 10
0
        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;
            ReadOnlyCollection <IWebElement> elements;
            string data             = "";
            string xpath            = "";
            string url              = "";
            IJavaScriptExecutor js  = (IJavaScriptExecutor)driver.GetDriver();
            VerifyError         err = new VerifyError();

            if (step.Name.Equals("Verify Main Nav Link Values"))
            {
                string[] dataSet = { "HOME", "SCORES", "LIVE TV", "STORIES", "SEARCH", "SIGN IN", "Account" };
                elements = driver.FindElements("xpath", "//ul[@class='nav']//li[contains(@class,'desktop-show')]//span[contains(@class,'nav-item-text')]");

                if (dataSet.Length != elements.Count)
                {
                    log.Error("Unexpected element count. Expected: [" + dataSet.Length + "] does not match Actual: [" + 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
                        {
                            log.Error("Verification FAILED. Expected: [" + dataSet[i] + "] does not match Actual: [" + elements[i].GetAttribute("innerText").Trim() + "]");
                            err.CreateVerificationError(step, dataSet[i], elements[i].GetAttribute("innerText").Trim());
                        }
                    }
                }
            }

            else if (step.Name.Equals("Verify URL Contains String"))
            {
                url = driver.GetDriver().Url.ToString();
                if (url.Contains(step.Data))
                {
                    log.Info("Verification Passed. Expected [" + step.Data + "]" + " can be found in Actual URL [" + url + "]");
                }
                else
                {
                    log.Error("Verification FAILED.*** Expected: [" + step.Data + "] is not within Actual URL [" + url + "]");
                    err.CreateVerificationError(step, step.Data, url);
                    driver.TakeScreenshot(DataManager.CaptureMap["TEST_ID"] + "_verification_failure_" + DataManager.VerifyErrors.Count);
                }
            }

            else if (step.Name.Equals("Store Sport by Data"))
            {
                DataManager.CaptureMap["SPORT"] = step.Data;
                log.Info("Storing " + step.Data + "to capture map as SPORT...");
            }

            else if (step.Name.Equals("Store Conference by Data"))
            {
                DataManager.CaptureMap["CONF"] = step.Data;
                log.Info("Storing " + step.Data + "to capture map as CONF...");
            }

            else if (step.Name.Equals("Navigate to URL by ENV"))
            {
                log.Info("Appending " + step.Data + " to ENV URL: " + TestParameters.GLOBAL_APP_URL);
                url = TestParameters.GLOBAL_APP_URL + step.Data;
                steps.Add(new TestStep(order, "Navigate to " + url, url, "navigate_to", "", "", wait));
                TestRunner.RunTestSteps(driver, null, steps);
                steps.Clear();
            }

            else if (step.Name.Equals("Navigate to External Scorestrip by ENV"))
            {
                if (TestParameters.GLOBAL_ENV.Equals("dev"))
                {
                    url = "dev-";
                }
                else if (TestParameters.GLOBAL_ENV.Equals("stg"))
                {
                    url = "stage-";
                }

                url = "https://" + url + "statics.foxsports.com/static/orion/scorestrip/index.html";

                steps.Add(new TestStep(order, "Navigate to " + url, url, "navigate_to", "", "", wait));
                TestRunner.RunTestSteps(driver, null, steps);
                steps.Clear();
            }

            else if (step.Name.Equals("Capture Window Handle"))
            {
                DataManager.CaptureMap["WINDOW_HANDLE"] = driver.GetDriver().CurrentWindowHandle;
                log.Info("Storing window handle as " + DataManager.CaptureMap["WINDOW_HANDLE"]);
            }

            else if (step.Name.Equals("Switch To New Tab"))
            {
                ReadOnlyCollection <string> windowHandles = driver.GetDriver().WindowHandles;

                log.Info("Total Count of Handles: " + windowHandles.Count);
                foreach (string handle in windowHandles)
                {
                    log.Info("Current Handle : " + handle);
                    if (!handle.Equals(DataManager.CaptureMap["WINDOW_HANDLE"]))
                    {
                        DataManager.CaptureMap["NEW_WINDOW_HANDLE"] = handle;
                    }
                }
                driver.GetDriver().SwitchTo().Window(DataManager.CaptureMap["NEW_WINDOW_HANDLE"]);
                log.Info("Storing new window handle as " + DataManager.CaptureMap["NEW_WINDOW_HANDLE"] + " and switching to new window.");
            }

            else if (step.Name.Equals("Close Current Tab"))
            {
                driver.GetDriver().Close();
                log.Info("Closing " + DataManager.CaptureMap["NEW_WINDOW_HANDLE"]);
            }

            else
            {
                throw new Exception("Test Step not found in script");
            }
        }
Ejemplo n.º 11
0
        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");
            }
        }
Ejemplo n.º 12
0
        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;
            ReadOnlyCollection <IWebElement> elements;
            string data             = "";
            string xpath            = "";
            string url              = "";
            IJavaScriptExecutor js  = (IJavaScriptExecutor)driver.GetDriver();
            VerifyError         err = new VerifyError();

            if (step.Name.Equals("Verify Main Nav Link Values"))
            {
                string[] dataSet = { "HOME", "SCORES", "LIVE TV", "STORIES", "SEARCH", "SIGN IN", "Account" };
                elements = driver.FindElements("xpath", "//ul[@class='nav']//li[contains(@class,'desktop-show')]//span[contains(@class,'nav-item-text')]");

                if (dataSet.Length != elements.Count)
                {
                    log.Error("Unexpected element count. Expected: [" + dataSet.Length + "] does not match Actual: [" + 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
                        {
                            log.Error("Verification FAILED. Expected: [" + dataSet[i] + "] does not match Actual: [" + elements[i].GetAttribute("innerText").Trim() + "]");
                            err.CreateVerificationError(step, dataSet[i], elements[i].GetAttribute("innerText").Trim());
                        }
                    }
                }
            }

            else if (step.Name.Equals("Verify URL Contains String"))
            {
                url = driver.GetDriver().Url.ToString();
                if (url.Contains(step.Data))
                {
                    log.Info("Verification Passed. Expected [" + step.Data + "]" + " can be found in Actual URL [" + url + "]");
                }
                else
                {
                    log.Error("Verification FAILED.*** Expected: [" + step.Data + "] is not within Actual URL [" + url + "]");
                    err.CreateVerificationError(step, step.Data, url);
                    driver.TakeScreenshot(DataManager.CaptureMap["TEST_ID"] + "_verification_failure_" + DataManager.VerifyErrors.Count);
                }
            }

            else if (step.Name.Equals("Store Sport by Data"))
            {
                DataManager.CaptureMap["SPORT"] = step.Data;
                log.Info("Storing " + step.Data + "to capture map as SPORT...");
            }

            else if (step.Name.Equals("Store Conference by Data"))
            {
                DataManager.CaptureMap["CONF"] = step.Data;
                log.Info("Storing " + step.Data + "to capture map as CONF...");
            }

            else if (step.Name.Equals("Navigate to URL by ENV"))
            {
                log.Info("Appending " + step.Data + " to ENV URL: " + TestParameters.GLOBAL_APP_URL);
                url = TestParameters.GLOBAL_APP_URL + step.Data;
                steps.Add(new TestStep(order, "Navigate to " + url, url, "navigate_to", "", "", wait));
                TestRunner.RunTestSteps(driver, null, steps);
                steps.Clear();
            }

            else
            {
                throw new Exception("Test Step not found in script");
            }
        }
Ejemplo n.º 13
0
        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");
            }
        }
Ejemplo n.º 14
0
        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");
            }
        }
Ejemplo n.º 15
0
        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");
            }
        }
Ejemplo n.º 16
0
        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> activePredJobConfigIDArray       = new List <string>();
            List <string> inactivePredJobConfigIDArray     = new List <string>();
            List <string> activePredJobConfigTypeIDArray   = new List <string>();
            List <string> inactivePredJobConfigTypeIDArray = 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> activePredConfigIDArray          = new List <string>();
            List <string> inactivePredConfigIDArray        = 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/prediction/job/configuration");
                json = JObject.Parse(jsonString);
            }
            //Getting data
            foreach (JToken x in json["result"])
            {
                if (x["ConfigurationStatus"].ToString().Equals("active"))
                {
                    //Active PredictionJobConfigurationID
                    if (x["PredictionJobConfigurationID"] != null)
                    {
                        activePredJobConfigIDArray.Add(x["PredictionJobConfigurationID"].ToString());
                    }
                    else
                    {
                        activePredJobConfigIDArray.Add("");
                    }
                    //Active Name
                    if (x["Name"] != null)
                    {
                        activeNameArray.Add(x["Name"].ToString());
                    }
                    else
                    {
                        activeNameArray.Add("");
                    }
                    //Active PredictionJobConfigurationTypeID
                    if (x["PredictionJobConfigurationTypeID"] != null)
                    {
                        activePredJobConfigTypeIDArray.Add(x["PredictionJobConfigurationTypeID"].ToString());
                    }
                    else
                    {
                        activePredJobConfigTypeIDArray.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 PredictionConfigurationID
                    if (x["PredictionConfigurationID"] != null)
                    {
                        activePredConfigIDArray.Add(x["PredictionConfigurationID"].ToString());
                    }
                    else
                    {
                        activePredConfigIDArray.Add("");
                    }
                }
            }
            Dictionary <string, string[]> dataDictionary = new Dictionary <string, string[]>();

            dataDictionary.Add("activePredJobConfigIDArray", activePredJobConfigIDArray.ToArray());
            dataDictionary.Add("activeNameArray", activeNameArray.ToArray());
            dataDictionary.Add("activePredJobConfigTypeIDArray", activePredJobConfigTypeIDArray.ToArray());
            dataDictionary.Add("activeJobSettingsArray", activeJobSettingsArray.ToArray());
            dataDictionary.Add("activeTriggerTrainArray", activeTriggerTrainArray.ToArray());
            dataDictionary.Add("activePredConfigIDArray", activePredConfigIDArray.ToArray());
            VerifyError err = new VerifyError();
            ReadOnlyCollection <IWebElement> elements;

            if (step.Name.Equals("Check Prediction Job ID"))
            {
                string[] id = dataDictionary["activePredJobConfigIDArray"];
                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 Prediction Job ID: " + id[i], "Actual Prediction Job ID: " + elements[i].GetAttribute("innerText"));
                        }
                    }
                }
                else
                {
                    log.Error("Can't find Prediction Job ID values");
                }
            }
            else if (step.Name.Equals("Check Prediction 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 Prediction Job Name: " + id[i], "Actual Prediction Job Name: " + elements[i].GetAttribute("innerText"));
                        }
                    }
                }
                else
                {
                    log.Error("Can't find Prediction Job Name values");
                }
            }
            else if (step.Name.Equals("Check Prediction Configuration ID"))
            {
                string[] id = dataDictionary["activePredConfigIDArray"];
                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 Prediction Config ID: " + id[i], "Actual Prediction Config ID: " + elements[i].GetAttribute("innerText"));
                        }
                    }
                }
                else
                {
                    log.Error("Can't find Prediction 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 Prediction Job with ID: " + dataDictionary["activePredJobConfigIDArray"][i], "", "click", "xpath", "/html/body/div/main/div/div[2]/table/tbody/tr/td[1][1][.='" + dataDictionary["activePredJobConfigIDArray"][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");
                    }
                }
            }
        }
Ejemplo n.º 17
0
        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");
            }
        }
Ejemplo n.º 18
0
        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();

            OpenQA.Selenium.Interactions.Actions actions = new OpenQA.Selenium.Interactions.Actions(driver.GetDriver());
            IWebElement ele;
            int         total   = 0;
            string      day     = "";
            string      data    = "";
            string      events  = "";
            string      games   = "";
            string      status  = "";
            string      date    = "";
            string      xpath   = "";
            bool        over    = false;
            bool        playoff = false;

            if (step.Name.Equals("Verify Event"))
            {
                if (DataManager.CaptureMap.ContainsKey("IN_SEASON"))
                {
                    DataManager.CaptureMap["GAME"] = step.Data;

                    //get date for scores id
                    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
                date = driver.FindElement("xpath", "//h2[contains(@class,'section-title fs-30 desktop-show') and not(@style='display: none;')]").GetAttribute("innerText").Substring(5);
                log.Info("Current segment: " + date);
                DataManager.CaptureMap["NFL_WEEK"] = date;
                day = DateTime.Now.DayOfWeek.ToString();

                if (date.Equals("CARD"))
                {
                    day = "NFL_Playoffs";
                    DataManager.CaptureMap["NFL_WEEK"] = "c";
                }
                else if (day.Equals("Tuesday") || day.Equals("Wednesday") || day.Equals("Thursday"))
                {
                    day = "NFL_Thursday";
                }
                else if (day.Equals("Friday") || day.Equals("Saturday") || day.Equals("Sunday"))
                {
                    day = "NFL_Sunday";
                }
                else
                {
                    day = "NFL_Monday";
                }

                steps.Add(new TestStep(order, "Run Segment by Day", day, "run_template", "xpath", "", wait));
                TestRunner.RunTestSteps(driver, null, steps);
                steps.Clear();
            }

            else if (step.Name.Equals("Verify Events by Day"))
            {
                DataManager.CaptureMap["NFL_DAY"] = step.Data;
                total = driver.FindElements("xpath", "//div[@class='scores' and contains (@id,'w" + DataManager.CaptureMap["NFL_WEEK"] + step.Data + "')]//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,'w" + DataManager.CaptureMap["NFL_WEEK"] + step.Data + "')]//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"))
                    {
                        events = "Football_FutureEvent";
                        DataManager.CaptureMap["EVENT_STATUS"] = "FUTURE";
                    }
                    else if (games.Equals("live"))
                    {
                        events = "TeamSport_LiveEvent";
                        DataManager.CaptureMap["EVENT_STATUS"] = "LIVE";
                    }
                    else
                    {
                        status = driver.FindElement("xpath", "//div[@class='scores' and contains (@id,'" + DataManager.CaptureMap["NFL_WEEK"] + step.Data + "')]//a[contains(@class,'score-chip')][" + game + "]//div[contains(@class,'status-text')]").Text;
                        log.Info("Event status: " + status);
                        if (status.Equals("POSTPONED") || status.Equals("CANCELED"))
                        {
                            events = "TeamSport_PostponedEvent";
                            DataManager.CaptureMap["EVENT_STATUS"] = "POSTPONED";
                        }
                        else
                        {
                            events = "TeamSport_PastEvent";
                            DataManager.CaptureMap["EVENT_STATUS"] = "FINAL";
                        }
                    }

                    steps.Add(new TestStep(order, "Run Event Template", events, "run_template", "xpath", "", wait));
                    TestRunner.RunTestSteps(driver, null, steps);
                    steps.Clear();

                    steps.Add(new TestStep(order, "Return to Scores Segment", "TeamSport_ScoresToday", "run_template", "xpath", "", wait));
                    TestRunner.RunTestSteps(driver, null, steps);
                    steps.Clear();
                }
            }

            else if (step.Name.Equals("Scroll to Sunday"))
            {
                ele = driver.FindElement("xpath", "//div[@class='scores' and contains (@id,'w" + DataManager.CaptureMap["NFL_WEEK"] + "sun" + "')]");
                js.ExecuteScript("arguments[0].scrollIntoView(true);", ele);
                actions.MoveToElement(ele).Perform();
            }

            else if (step.Name.Equals("Click Scorechip By Number"))
            {
                data = step.Data;
                steps.Add(new TestStep(order, "Click Event " + data, "", "click", "xpath", "//div[@class='scores' and contains (@id,'w" + DataManager.CaptureMap["NFL_WEEK"] + DataManager.CaptureMap["NFL_DAY"] + "')]//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;
                xpath = "//div[contains(@id,'w" + DataManager.CaptureMap["NFL_WEEK"] + DataManager.CaptureMap["NFL_DAY"] + "')]";

                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"))
                {
                    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
            {
                throw new Exception("Test Step not found in script");
            }
        }
Ejemplo n.º 19
0
        public void Execute(DriverManager driver, TestStep step)
        {
            long            order = step.Order;
            string          wait  = step.Wait != null ? step.Wait : "";
            string          title;
            string          conf = "";
            int             week;
            int             total;
            Random          random = new Random();
            VerifyError     err    = new VerifyError();
            List <TestStep> steps  = new List <TestStep>();

            //"BOWLS", "TOP 25",
            string[] expectedConf = { "BOWLS", "TOP 25", "FBS (I-A)", "AAC", "ACC", "BIG 12", "BIG SKY", "BIG SOUTH", "BIG TEN", "C-USA", "CAA", "IND-FBS", "IND-FCS", "IVY", "MAC", "MEAC", "MVC", "MW", "NEC", "OVC", "PAC-12", "PATRIOT", "PIONEER", "SEC", "SOUTHERN", "SOUTHLND", "SUN BELT", "SW ATH" };

            string[] regSeason       = { "August", "September", "October", "November", "December" };
            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" };
            string[] postSeason      = { "December", "January" };
            string[] postSeasonWeeks = { "BOWL WEEK" };

            if (step.Name.Equals("Verify CFB Groups"))
            {
                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));
                TestRunner.RunTestSteps(driver, null, steps);
                steps.Clear();

                var conferences = driver.FindElements("xpath", "//div[contains(@class,'scores-home-container')]//div[contains(@class,'dropdown-root active')]//ul//li");
                for (int i = 0; i < conferences.Count; i++)
                {
                    if (expectedConf[i].Equals(conferences[i].GetAttribute("innerText")))
                    {
                        log.Info("Success. " + expectedConf[i] + " matches " + conferences[i].GetAttribute("innerText"));
                    }
                    else
                    {
                        log.Error("***Verification FAILED. Expected data [" + expectedConf[i] + "] does not match actual data [" + conferences[i].GetAttribute("innerText") + "] ***");
                        err.CreateVerificationError(step, expectedConf[i], conferences[i].GetAttribute("innerText"));
                    }
                }
            }

            else if (step.Name.Equals("Select Regular Season CFB Date"))
            {
                title = "//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", "CFB_WEEK", "capture", "xpath", "(" + title + ")[" + week + "]//div//div[1]", wait));
                steps.Add(new TestStep(order, "Capture Dates", "CFB_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.Equals("Check Conference Name"))
            {
                switch (step.Data)
                {
                case "AAC":
                    conf = "American Athletic";
                    break;

                case "C-USA":
                    conf = "Conference USA";
                    break;

                case "CAA":
                    conf = "Colonial Athletic";
                    break;

                case "IND-FCS":
                    conf = "Independents (FCS)";
                    break;

                case "Independents":
                    conf = "Independents (FBS)";
                    break;

                case "MAC":
                    conf = "Mid-American";
                    break;

                case "MEAC":
                    conf = "Mid-Eastern Athletic";
                    break;

                case "MVC":
                    conf = "Missouri Valley";
                    break;

                case "MW":
                    conf = "Mountain West";
                    break;

                case "NEC":
                    conf = "Northeast";
                    break;

                case "OVC":
                    conf = "Ohio Valley";
                    break;

                case "SWAC":
                    conf = "Southwestern Athletic";
                    break;

                default:
                    conf = DataManager.CaptureMap["RANDOM_CONF"];
                    break;
                }
                DataManager.CaptureMap["RANDOM_CONF"] = conf;
            }


            else if (step.Name.Contains("Verify College") && step.Name.Contains("Header Text"))
            {
                if (step.Name.Contains("Football"))
                {
                    step.Data = step.Data + " FOOTBALL";
                }
                else if (step.Name.Contains("Basketball"))
                {
                    step.Data = step.Data + " BASKETBALL";
                }

                steps.Add(new TestStep(order, "Verify Header Text", step.Data, "verify_value", "xpath", "//div[contains(@class,'entity-header')]//div[contains(@class,'entity-title')]", wait));
                TestRunner.RunTestSteps(driver, null, steps);
                steps.Clear();
            }


            else
            {
                throw new Exception("Test Step not found in script");
            }
        }
Ejemplo n.º 20
0
        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 <string>       polls     = new List <string>();
            List <TestStep>     steps     = new List <TestStep>();
            IWebElement         ele;
            string              sport    = "";
            string              games    = " GAMES ";
            string              player   = "";
            string              playoffs = "";
            string              xpath    = "";
            bool                skip     = false;
            int                 count    = 0;
            int                 total    = 0;
            int                 size;
            int                 upper = 0;
            int                 lower = 0;
            IWebElement         element;
            IJavaScriptExecutor js = (IJavaScriptExecutor)driver.GetDriver();

            if (step.Name.Equals("Click Pagination Link by Number"))
            {
                steps.Add(new TestStep(order, "Click " + step.Data, "", "click", "xpath", "//nav[@class='pagination']//a[text()='" + step.Data + "']", wait));
                TestRunner.RunTestSteps(driver, null, steps);
                steps.Clear();
            }

            else if (step.Name.Equals("Verify Standings Dropdown List By Sport"))
            {
                if (DataManager.CaptureMap.ContainsKey("SPORT"))
                {
                    sport = DataManager.CaptureMap["SPORT"];
                }
                else
                {
                    sport = driver.FindElement("xpath", "//div[contains(@class,'entity-title')]").Text;
                }

                size = 1;
                switch (sport)
                {
                case "NFL":
                    standings.Add("DIVISION");
                    standings.Add("CONFERENCE");
                    //standings.Add("PRESEASON");
                    break;

                case "NBA":
                    standings.Add("CONFERENCE");
                    standings.Add("DIVISION");
                    standings.Add("PRESEASON");
                    break;

                case "NHL":
                    standings.Add("CONFERENCE");
                    standings.Add("DIVISION");
                    standings.Add("WILD CARD");
                    standings.Add("PRESEASON");
                    break;

                case "MLB":
                    standings.Add("DIVISION");
                    standings.Add("WILD CARD");
                    standings.Add("SPRING TRAINING");
                    break;

                case "ACC FOOTBALL":
                case "BIG 12 FOOTBALL":
                case "BIG TEN FOOTBALL":
                case "PAC-12 FOOTBALL":
                case "SEC FOOTBALL":
                    standings.Add("CONFERENCE");
                    break;

                default:
                    standings.Add("");
                    standings.Add("");
                    standings.Add("");
                    break;
                }

                foreach (string s in standings)
                {
                    steps.Add(new TestStep(order, "Verify Dropdown Value " + size, standings[size - 1], "verify_value", "xpath", "//div[contains(@class,'standings')]//ul//li[contains(@class,'dropdown')][" + size + "]", wait));
                    TestRunner.RunTestSteps(driver, null, steps);
                    steps.Clear();
                    size++;
                }
            }

            else if (step.Name.Equals("Verify Count of Teams"))
            {
                sport = step.Data;
                bool success = Int32.TryParse(sport, out total);

                if (!success)
                {
                    switch (sport)
                    {
                    case "NFL":
                        sport = "32";
                        break;

                    case "NBA":
                        sport = "30";
                        break;

                    case "NHL":
                        sport = "31";
                        break;

                    case "MLB":
                        sport = "30";
                        break;

                    case "BIG TEN FOOTBALL":
                    case "SEC FOOTBALL":
                        sport = "14";
                        break;

                    case "ACC FOOTBALL":
                        sport = "15";
                        break;

                    case "PAC-12 FOOTBALL":
                        sport = "12";
                        break;

                    case "BIG 12 FOOTBALL":
                        sport = "10";
                        break;

                    default:
                        sport = "32";
                        break;
                    }
                }

                steps.Add(new TestStep(order, "Verify Count", sport, "verify_count", "xpath", "//div[contains(@class,'teams-list')]//a", wait));
                TestRunner.RunTestSteps(driver, null, steps);
                steps.Clear();
            }

            else if (step.Name.Equals("Verify Number of Player Stats Categories") || step.Name.Equals("Verify Number of Team Stats Categories"))
            {
                sport  = step.Data;
                player = step.Data;
                bool success = Int32.TryParse(sport, out total);

                if (!success)
                {
                    switch (sport)
                    {
                    case "NFL":
                        player = "16";
                        sport  = "11";
                        break;

                    case "NBA":
                        player = "8";
                        sport  = "8";
                        break;

                    case "NHL":
                        player = "10";
                        sport  = "7";
                        break;

                    case "MLB":
                        player = "15";
                        sport  = "14";
                        break;

                    case "NCAA FOOTBALL":
                    case "ACC FOOTBALL":
                    case "BIG 12 FOOTBALL":
                    case "BIG TEN FOOTBALL":
                    case "PAC-12 FOOTBALL":
                    case "SEC FOOTBALL":
                        player = "14";
                        sport  = "9";
                        break;

                    default:
                        player = "";
                        sport  = "";
                        break;
                    }
                }

                if (step.Name.Contains("Player Stats"))
                {
                    steps.Add(new TestStep(order, "Verify Count", player, "verify_count", "xpath", "//div[contains(@class,'stats-overview-component')][div[.='PLAYER STATS']]//a[contains(@class,'stats-overview')]", wait));
                }
                else if (step.Name.Contains("Team Stats"))
                {
                    steps.Add(new TestStep(order, "Verify Count", sport, "verify_count", "xpath", "//div[contains(@class,'stats-overview-component')][div[.='TEAM STATS']]//a[contains(@class,'stats-overview')]", wait));
                }
                TestRunner.RunTestSteps(driver, null, steps);
                steps.Clear();
            }

            else if (step.Name.Equals("Verify Tweet is Displayed"))
            {
                count = driver.FindElements("xpath", "//div[@class='loader']").Count;

                while (count != 0 && total < 5)
                {
                    log.Info("Spinners found: " + count + ". Waiting for social posts to load.");
                    Thread.Sleep(1000);
                    count = driver.FindElements("xpath", "//div[@class='loader']").Count;
                    total++;
                }

                steps.Add(new TestStep(order, "Verify Tweet", "", "verify_displayed", "xpath", "//*[contains(@id,'twitter-widget')]", wait));
                TestRunner.RunTestSteps(driver, null, steps);
                steps.Clear();
            }

            else if (step.Name.Equals("Verify Header Subtext"))
            {
                sport = step.Data;
                count = driver.FindElements("xpath", "(//div[@class='scores'])[1]//a").Count;

                if (count == 1)
                {
                    games = " GAME ";
                }

                switch (sport)
                {
                case "NFL":
                    driver.FindElement("xpath", "//div[contains(@class,'scores-app-root')]/div[not(@style='display: none;')]//span[@class='title-text']").Click();
                    sport  = driver.FindElement("xpath", "//div[contains(@class,'week-selector') and contains(@class,'active')]//li[contains(@class,'selected')]//div[contains(@class,'week')]//div[1]").Text;
                    player = driver.FindElement("xpath", "//div[contains(@class,'week-selector') and contains(@class,'active')]//li[contains(@class,'selected')]//div[contains(@class,'week')]//div[2]").Text;
                    if (sport.StartsWith("PRE"))
                    {
                        sport = sport.Replace("PRE", "PRESEASON");
                    }
                    sport = sport + ": " + player;
                    break;

                case "NCAA FOOTBALL":
                    driver.FindElement("xpath", "//div[contains(@class,'scores-app-root')]/div[not(@style='display: none;')]//span[@class='title-text']").Click();
                    sport  = driver.FindElement("xpath", "//div[contains(@class,'week-selector') and contains(@class,'active')]//li[contains(@class,'selected')]//div[contains(@class,'week')]//div[1]").Text;
                    player = driver.FindElement("xpath", "//div[contains(@class,'week-selector') and contains(@class,'active')]//li[contains(@class,'selected')]//div[contains(@class,'week')]//div[2]").Text;
                    sport  = sport + ": " + player;
                    break;

                case "NBA":
                    DateTime NBA_season  = new DateTime(2021, 1, 01);
                    DateTime NBA_playoff = new DateTime(2021, 7, 30);
                    if (DateTime.Now > NBA_season)
                    {
                        sport = driver.FindElement("xpath", "//div[contains(@class,'date-picker-container') and @style]//span[@class='title-text']").Text;
                    }
                    else
                    {
                        skip = true;
                    }
                    if (DateTime.Now > NBA_playoff)
                    {
                        playoffs = "PLAYOFFS: ";
                    }
                    sport = playoffs + count + games + sport;
                    break;

                case "NHL":
                    DateTime NHL_season  = new DateTime(2021, 1, 01);
                    DateTime NHL_playoff = new DateTime(2021, 5, 30);
                    if (DateTime.Now > NHL_season)
                    {
                        sport = driver.FindElement("xpath", "//div[contains(@class,'date-picker-container') and @style]//span[@class='title-text']").Text;
                    }
                    else
                    {
                        skip = true;
                    }
                    if (DateTime.Now > NHL_playoff)
                    {
                        playoffs = "PLAYOFFS: ";
                    }
                    sport = count + games + sport;
                    break;

                case "MLB":
                    DateTime MLB_season  = new DateTime(2021, 4, 01);
                    DateTime MLB_playoff = new DateTime(2021, 10, 04);
                    if (DateTime.Now > MLB_season)
                    {
                        sport = driver.FindElement("xpath", "//div[contains(@class,'date-picker-container') and @style]//span[@class='title-text']").Text;
                    }
                    else
                    {
                        skip = true;
                    }
                    if (DateTime.Now > MLB_playoff)
                    {
                        playoffs = "PLAYOFFS: ";
                    }
                    sport = playoffs + count + games + sport;
                    break;

                default:
                    break;
                }

                if (!skip)
                {
                    steps.Add(new TestStep(order, "Verify Text", sport, "verify_value", "xpath", "//div[contains(@class,'entity-header')]/div/span", wait));
                    TestRunner.RunTestSteps(driver, null, steps);
                    steps.Clear();
                }
                else
                {
                    log.Info("No subtext current for Out of Season sports. Skipping...");
                }
            }

            else if (step.Name.Equals("Capture Number of Players"))
            {
                total = driver.FindElements("xpath", "(//div[@class='table-roster'])[1]//tbody//tr").Count;
                log.Info("Storing total as " + total.ToString());
                DataManager.CaptureMap["PLAYER_COUNT"] = total.ToString();
            }

            else if (step.Name.Equals("Verify Polls Dropdown List"))
            {
                polls.Add("ASSOCIATED PRESS");
                polls.Add("USA TODAY COACHES POLL");

                size = 1;
                foreach (string s in polls)
                {
                    steps.Add(new TestStep(order, "Verify Polls List " + size, polls[size - 1], "verify_value", "xpath", "//div[contains(@class,'polls')]//ul//li[contains(@class,'dropdown')][" + size + "]", wait));
                    TestRunner.RunTestSteps(driver, null, steps);
                    steps.Clear();
                    size++;
                }
            }

            else if (step.Name.Equals("Click Open Standings Dropdown"))
            {
                xpath = "//div[contains(@class,'standings')]//a[contains(@class,'dropdown-title')]";
                ele   = driver.FindElement("xpath", xpath);
                js.ExecuteScript("window.scrollTo(0,0);");

                steps.Add(new TestStep(order, "Click Open Standings", "", "click", "xpath", xpath, wait));
                TestRunner.RunTestSteps(driver, null, steps);
                steps.Clear();
            }

            else if (step.Name.Equals("Verify Number of Stories & Videos"))
            {
                try {
                    upper = Int32.Parse(step.Data);
                    lower = upper - 2;
                }
                catch (Exception e) {
                    log.Error("Expected data to be a numeral. Setting data to 0.");
                    upper = 0;
                }
                size = driver.FindElements("xpath", "//*[@class='news' or @class='news pointer-default' or contains(@class,'video-container')]").Count;
                if (size >= lower && size <= upper)
                {
                    log.Info("Verification Passed. " + size + " is between " + lower + " and " + upper);
                }
                else
                {
                    log.Info("Verification FAILED. " + size + " is not between " + lower + " and " + upper);
                    err.CreateVerificationError(step, "Number Between " + lower + " and " + upper.ToString(), size.ToString());
                    driver.TakeScreenshot(DataManager.CaptureMap["TEST_ID"] + "_verification_failure_" + DataManager.VerifyErrors.Count);
                }
            }

            else
            {
                throw new Exception("Test Step not found in script");
            }
        }
Ejemplo n.º 21
0
        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");
            }
        }
Ejemplo n.º 22
0
        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");
            }
        }
Ejemplo n.º 23
0
        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)");
                }
            }
        }
Ejemplo n.º 24
0
        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)");
                }
            }
        }
Ejemplo n.º 25
0
        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");
            }
        }
Ejemplo n.º 26
0
        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             episode       = 1;
            int             attempts      = 10;
            string          classList     = "";
            string          edit          = "";
            string          top           = "";
            string          episodeNumber = "";
            string          title         = "";
            bool            topTitle      = true;
            bool            live          = false;
            List <TestStep> steps         = new List <TestStep>();
            VerifyError     err           = new VerifyError();

            if (step.Name.Equals("Capture Episode Title"))
            {
                episode = Int32.Parse(DataManager.CaptureMap["CURRENT_EPISODE_NUM"]);
                string eTitle = driver.FindElement("xpath", "(//div[contains(@class,'pdg-top-20')])[" + episode + "]").GetAttribute("innerText");
                DataManager.CaptureMap["TITLE"] = eTitle;
                log.Info("Episode Title: " + eTitle);
            }

            else if (step.Name.Equals("Capture Number of Episodes"))
            {
                size = driver.FindElements("xpath", "//div[contains(@class,'video-overlay')]").Count;
                if (size == 0)
                {
                    log.Info("***THERE ARE NO EPIOSODES POSTED***");
                }
                DataManager.CaptureMap["EPISODES"] = size.ToString();
                log.Info("Number of additional episodes: " + size);
            }

            else if (step.Name.Equals("Select Additional Episodes"))
            {
                if (DataManager.CaptureMap.ContainsKey("EPISODES"))
                {
                    size = Int32.Parse(DataManager.CaptureMap["EPISODES"]);
                    for (int i = 1; i <= size; i++)
                    {
                        steps.Add(new TestStep(order, "Run Template", "Shows_Episodes_temp", "run_template", "xpath", "", wait));
                        DataManager.CaptureMap["CURRENT_EPISODE_NUM"] = i.ToString();
                        TestRunner.RunTestSteps(driver, null, steps);
                        steps.Clear();
                    }
                }
            }

            else if (step.Name.Equals("Select Additional Episode"))
            {
                //if (DataManager.CaptureMap.ContainsKey("EPISODES " +""))
                //{
                episode = Int32.Parse(DataManager.CaptureMap["CURRENT_EPISODE_NUM"]);
                steps.Clear();
                string eTitle = DataManager.CaptureMap["TITLE"];
                episodeNumber = driver.FindElement("xpath", "(//div[contains(@class,'video-overlay')])[1]").GetAttribute("aria-label");

                steps.Add(new TestStep(order, "Select Episode " + episode + " - " + episodeNumber, "", "click", "xpath", "(//div[contains(@class,'video-overlay')])[1]", wait));
                TestRunner.RunTestSteps(driver, null, steps);
                steps.Clear();
                //}
            }

            if (step.Name.Equals("Verify Video is Playing"))
            {
                episode = Int32.Parse(DataManager.CaptureMap["CURRENT_EPISODE_NUM"]);
                string eTitle = DataManager.CaptureMap["TITLE"];

                ele       = driver.FindElement("xpath", "//div[@class='mgn-btm-35'][//div[contains(@class,'fs-21') and contains(.,'" + eTitle + "')]]//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'])[" + episode + "]");
                        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);
                }
            }
        }
Ejemplo n.º 27
0
        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");
            }
        }
Ejemplo n.º 28
0
        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      = "";
            List <string>       confTeams = new List <string>();
            string              team1     = "";
            string              team2     = "";
            IJavaScriptExecutor js        = (IJavaScriptExecutor)driver.GetDriver();
            VerifyError         err       = new VerifyError();
            ReadOnlyCollection <IWebElement> elements;
            int count = 0;

            if (step.Name.Contains("Verify Top Action by Conference"))
            {
                // set teams for each conference
                switch (step.Data)
                {
                case "ACC":
                    string[] acc = { "BOSTON COLLEGE", "CLEMSON", "DUKE", "FLORIDA STATE", "GEORGIA TECH", "LOUISVILLE", "MIAMI (FL)", "NORTH CAROLINA STATE", "NORTH CAROLINA", "NOTRE DAME", "PITTSBURGH", "SYRACUSE", "VIRGINIA", "VIRGINIA TECH", "WAKE FOREST" };
                    confTeams.AddRange(acc);
                    break;

                case "Big 12":
                    string[] bigTwelve = { "BAYLOR", "IOWA STATE", "KANSAS", "KANSAS STATE", "OKLAHOMA", "OKLAHOMA STATE", "TCU", "TEXAS", "TEXAS TECH", "WEST VIRGINIA" };
                    confTeams.AddRange(bigTwelve);
                    break;

                case "Big East":
                    string[] bigEast = { "BUTLER", "CONNECTICUT", "CREIGHTON", "DEPAUL", "GEORGETOWN", "MARQUETTE", "PROVIDENCE", "SETON HALL", "ST. JOHN'S", "VILLANOVA", "XAVIER" };
                    confTeams.AddRange(bigEast);
                    break;

                case "Big Ten":
                case "Big 10":
                case "B1G":
                    string[] bigTen = { "ILLINOIS", "INDIANA", "IOWA", "MARYLAND", "MICHIGAN STATE", "MICHIGAN", "MINNESOTA", "NEBRASKA", "NORTHWESTERN", "OHIO STATE", "PENN STATE", "PURDUE", "RUTGERS", "WISCONSIN" };
                    confTeams.AddRange(bigTen);
                    break;

                case "Pac-12":
                    string[] pac = { "ARIZONA STATE", "ARIZONA", "CALIFORNIA", "COLORADO", "OREGON", "OREGON STATE", "STANFORD", "UCLA", "USC", "UTAH", "WASHINGTON", "WASHINGTON STATE" };
                    confTeams.AddRange(pac);
                    break;

                case "SEC":
                    string[] sec = { "ALABAMA", "ARKANSAS", "AUBURN", "FLORIDA", "GEORGIA", "KENTUCKY", "LSU", "MISSISSIPPI STATE", "MISSOURI", "OLE MISS", "SOUTH CAROLINA", "TENNESSEE", "TEXAS A&M", "VANDERBILT" };
                    confTeams.AddRange(sec);
                    break;

                default:

                    break;
                }
                count = driver.FindElements("xpath", "//a[contains(@class,'event-card')]").Count;
                if (count > 0)
                {
                    for (int i = 1; i <= count; i++)
                    {
                        team1 = driver.FindElement("xpath", "((//div[contains(@class,'event-card')])[" + i + "]//div[contains(@class,'fs-14')])[1]").Text;
                        team2 = driver.FindElement("xpath", "((//div[contains(@class,'event-card')])[" + i + "]//div[contains(@class,'fs-14')])[2]").Text;
                        if (confTeams.Contains(team1) || confTeams.Contains(team2))
                        {
                            log.Info("VERIFICATION PASSED. " + team1 + " or " + team2 + " is in " + step.Data + " conference.");
                        }
                        else
                        {
                            log.Error("***VERIFICATION FAILED. " + team1 + " or " + team2 + " is NOT in " + step.Data + " conference.");
                            err.CreateVerificationError(step, step.Data + " Team", team1 + " & " + team2);
                            driver.TakeScreenshot(DataManager.CaptureMap["TEST_ID"] + "_verification_failure_" + DataManager.VerifyErrors.Count);
                        }
                    }
                }
                else
                {
                    log.Warn("No Games Found under " + step.Data + " Odds");
                    steps.Add(new TestStep(order, "Verify Number of Header Items", "- No Data Available -", "verify_value", "xpath", "//div[contains(@class,'no-data')]", wait));
                    TestRunner.RunTestSteps(driver, null, steps);
                    steps.Clear();
                }
            }

            else
            {
                throw new Exception("Test Step not found in script");
            }
        }
Ejemplo n.º 29
0
        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");
            }
        }
Ejemplo n.º 30
0
        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> activeModelConfigIDArray     = new List <string>();
            List <string> inactiveModelConfigIDArray   = new List <string>();
            List <string> activeAlgoSpecIDArray        = new List <string>();
            List <string> inactiveAlgoSpecIDArray      = new List <string>();
            List <string> activeTrainKeyIDArray        = new List <string>();
            List <string> inactiveTrainKeyIDArray      = new List <string>();
            List <string> activeHyperParamIDArray      = new List <string>();
            List <string> inactiveHyperParamIDArray    = new List <string>();
            List <string> activeHyperParamsArray       = new List <string>();
            List <string> inactiveHyperParamsArray     = new List <string>();
            List <string> activeModelConfigNameArray   = new List <string>();
            List <string> inactiveModelConfigNameArray = 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/model/configuration");
                json = JObject.Parse(jsonString);
            }
            //Getting data
            foreach (JToken x in json["result"])
            {
                if (x["Status"].ToString().Equals("active"))
                {
                    //Active ModelConfigurationID
                    if (x["ModelConfigurationID"] != null)
                    {
                        activeModelConfigIDArray.Add(x["ModelConfigurationID"].ToString());
                    }
                    else
                    {
                        activeModelConfigIDArray.Add("");
                    }
                    //Active AlgoSpecID
                    if (x["AlgoSpecificationID"] != null)
                    {
                        activeAlgoSpecIDArray.Add(x["AlgoSpecificationID"].ToString());
                    }
                    else
                    {
                        activeAlgoSpecIDArray.Add("");
                    }
                    //Active TrainingKeyID
                    if (x["TrainingKeyID"] != null)
                    {
                        activeTrainKeyIDArray.Add(x["TrainingKeyID"].ToString());
                    }
                    else
                    {
                        activeTrainKeyIDArray.Add("");
                    }
                    //Ative HyperparameterID
                    if (x["HyperparameterID"] != null)
                    {
                        activeHyperParamIDArray.Add(x["HyperparameterID"].ToString());
                    }
                    else
                    {
                        activeHyperParamIDArray.Add("");
                    }
                    //Active Hyperparameters
                    if (x["Hyperparameters"] != null)
                    {
                        activeHyperParamsArray.Add(x["Hyperparameters"].ToString());
                    }
                    else
                    {
                        activeHyperParamsArray.Add("");
                    }
                    //Active ModelConfigurationName
                    if (x["ModelConfigurationName"] != null)
                    {
                        activeModelConfigNameArray.Add(x["ModelConfigurationName"].ToString());
                    }
                    else
                    {
                        activeModelConfigNameArray.Add("");
                    }
                }
            }
            Dictionary <string, string[]> dataDictionary = new Dictionary <string, string[]>();

            dataDictionary.Add("activeModelConfigID", activeModelConfigIDArray.ToArray());
            dataDictionary.Add("activeAlgoSpecID", activeAlgoSpecIDArray.ToArray());
            dataDictionary.Add("activeTrainingKeyID", activeTrainKeyIDArray.ToArray());
            dataDictionary.Add("activeHyperparameterID", activeHyperParamIDArray.ToArray());
            dataDictionary.Add("activeHyperparameters", activeHyperParamsArray.ToArray());
            dataDictionary.Add("activeModelConfigName", activeModelConfigNameArray.ToArray());
            VerifyError err = new VerifyError();
            ReadOnlyCollection <IWebElement> elements;

            if (step.Name.Equals("Check Model ID"))
            {
                string[] id = dataDictionary["activeModelConfigID"];
                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[i].GetAttribute("innerText").Equals(id[i]))
                        {
                            log.Info("Match! " + "Expected: " + id[i] + "  Actual: " + elements[i].GetAttribute("innerText"));
                        }
                        else
                        {
                            err.CreateVerificationError(step, "Expected ID: " + id[i], "Actual ID: " + elements[i].GetAttribute("innerText"));
                        }
                    }
                }
                else
                {
                    log.Error("Can't find ID values");
                }
            }
            else if (step.Name.Equals("Check Model Name"))
            {
                string[] id = dataDictionary["activeModelConfigName"];
                elements = driver.FindElements("xpath", "/html/body/div/main/div/div[1]/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 Name: " + id[i], "Actual Name: " + elements[i].GetAttribute("innerText"));
                        }
                    }
                }
                else
                {
                    log.Error("Can't find Name values");
                }
            }
            else if (step.Name.Equals("Check Model Alg Spec"))
            {
                string[] id = dataDictionary["activeAlgoSpecID"];
                elements = driver.FindElements("xpath", "/html/body/div[1]/main/div/div[1]/table/tbody/tr/td[3]/div/div/div/div/div[2]/form/div[1]/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 Alg Spec: " + id[i], "Actual Alg Spec: " + elements[i].GetAttribute("innerText"));
                        }
                    }
                }
                else
                {
                    log.Error("Can't find Alg Spec values");
                }
            }
            else if (step.Name.Equals("Check Model Training Key"))
            {
                string[] id = dataDictionary["activeTrainingKeyID"];
                elements = driver.FindElements("xpath", "/html/body/div[1]/main/div/div[1]/table/tbody/tr/td[4]/div/div/div/div/div[2]/form/div[1]/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 Key: " + id[i], "Actual Training Key: " + elements[i].GetAttribute("innerText"));
                        }
                    }
                }
                else
                {
                    log.Error("Can't find Training Key values");
                }
            }
            else if (step.Name.Equals("Check Model Hyperparameter Key"))
            {
                string[] id = dataDictionary["activeHyperparameterID"];
                elements = driver.FindElements("xpath", "/html/body/div/main/div/div[1]/table/tbody/tr/td[5]");
                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 Hyperparam Key: " + id[i], "Actual Hyperparam Key: " + elements[i].GetAttribute("innerText"));
                        }
                    }
                }
                else
                {
                    log.Error("Can't find Hyperparameter Key values");
                }
            }
        }