コード例 #1
0
ファイル: GMM.cs プロジェクト: oohmyrose/ConsoleApplication1
        public static void UpdateOdds(string eventid)
        {
            Report.Case("GMM Update Odds", "GMM updates odds of the event we created");
            var    gmmMMPage = new GMMMMPage(driver);
            Random random    = new Random();

            #region (1) Fetch every cells of the event
            ElementVerify.Exist(driver, By.Id("evt" + eventid));
            IWebElement eventTable          = ElementVerify.Exist(driver, By.XPath("//*[@id='evt" + eventid + "']"));
            ICollection <IWebElement> cells = eventTable.FindElements(By.TagName("td"));
            #endregion

            #region (2) Key odds
            int cellcount = 1;
            foreach (var cell in cells)
            {
                if (cell.FindElement(By.XPath("div")).GetAttribute("class") == "odds")
                {
                    // Without Spread
                    if (cell.GetAttribute("wsml") == "false")
                    {
                        cell.FindElement(By.XPath("div/a")).ClickOnIt("oddsbox");
                        ElementVerify.Exist(driver, gmmMMPage.NoHandicapOdds);
                        ICollection <IWebElement> oddsEuros = driver.FindElements(gmmMMPage.NoHandicapOdds);
                        foreach (var oddsEuro in oddsEuros)
                        {
                            oddsEuro.EnterText("Euro Odds", random.Next(2, 15).ToString());
                            WriteConsole.Cyan(String.Format("Cell Number {0} : you key in odds {1}", cellcount, random));
                            Report.Log(LogStatus.Pass, "Update odds", String.Format("Cell Number {0} : you key in odds {1}", cellcount, random));
                        }

                        ElementVerify.Exist(driver, gmmMMPage.OddsSaveButton).ClickOnIt("Save Button");
                    }
                    // With Spread
                    else
                    {
                        double handicap = random.Next(0, 15) + 0.5;

                        cell.FindElement(By.XPath("div/a")).ClickOnIt("oddsbox");
                        if (ElementVerify.Exist(driver, gmmMMPage.HandicapOdds, 3) != null)
                        {
                            if (ElementVerify.PresenceAll(driver, gmmMMPage.HandicapDropdown) != null)
                            {
                                ElementVerify.PresenceAll(driver, gmmMMPage.HandicapDropdown).SelectByText("handicap Line", handicap.ToString());
                            }
                            else if (ElementVerify.Exist(driver, gmmMMPage.HandicapTextbox, 3) != null)
                            {
                                ElementVerify.Exist(driver, gmmMMPage.HandicapTextbox).EnterText("handicap Line", handicap.ToString());
                            }
                            ElementVerify.Exist(driver, gmmMMPage.HandicapOdds).EnterText("Home Odds", random.NextDouble().ToString("0.##"));
                            ElementVerify.Exist(driver, gmmMMPage.HandicapOdds).SendKeys(Keys.Enter);
                        }
                        else if (ElementVerify.Exist(driver, gmmMMPage.NoHandicapOdds, 3) != null)
                        {
                            ElementVerify.Exist(driver, gmmMMPage.NoHandicapOdds).EnterText("Home Odds", random.NextDouble().ToString("0.##"));
                            ElementVerify.Exist(driver, gmmMMPage.NoHandicapOdds).SendKeys(Keys.Enter);
                        }

                        WriteConsole.Cyan(String.Format("Cell Number {0} : you key in odds {1}", cellcount, random));
                        Report.Log(LogStatus.Pass, "Update odds", String.Format("Cell Number {0} : you key in odds {1}", cellcount, random));
                    }
                }
                else
                {
                    WriteConsole.Cyan(String.Format("Cell Number {0} : This is not the odds link", cellcount));
                }
                cellcount++;
            }
            #endregion
            Thread.Sleep(1000);
            Report.PrintScreen(driver);
        }