Exemplo n.º 1
0
        public static string CreateEvent()
        {
            Report.Case("GMM Create Event", "GMM Creates a fixture event and fetch the event id");
            DateTime inplaytime     = DateTime.Now.AddHours(-14);     //2 hours before NOW  ---- Local(GMT+8),Server(GMT-4)
            var      gmmMenu        = new GMMMenu(driver);
            var      gmmCreateEvent = new GMMCreateEvent(driver);

            #region (1) Go to EventCreate Page
            ElementVerify.Exist(driver, gmmMenu.Sportsbook).ClickOnIt("Sportsbook");
            ElementVerify.Exist(driver, gmmMenu.Event).MouseOver(driver, "Event");
            ElementVerify.Exist(driver, gmmMenu.FixtureEvent).ClickOnIt("Fixture Event");
            ElementVerify.Exist(driver, gmmCreateEvent.Create).ClickOnIt("Create Button");
            #endregion
            #region (2) Select sport / competition / participant ..
            // Sport
            ElementVerify.Exist(driver, gmmCreateEvent.SportDropdown).SelectByText("CreateEventPage Sport", sport);

            // Competition in dynamic dropdownlist
            ElementVerify.Exist(driver, By.CssSelector("#mainContent_CompetitionDropDownList > option[title='" + competition + "']"));
            ElementVerify.Exist(driver, gmmCreateEvent.CompetitionDropdown).SelectByText("CreateEventPage Competition", competition);

            // Home Away
            ElementVerify.Exist(driver, By.CssSelector("#mainContent_HomeRunnerDropDownList > option[title='" + home + "']"));
            ElementVerify.Exist(driver, gmmCreateEvent.HomeDropdown).SelectByText("CreateEventPage Home", home);
            ElementVerify.Exist(driver, gmmCreateEvent.AwayDropdown).SelectByText("CreateEventPage Away", away);

            // In-Play
            ElementVerify.Exist(driver, gmmCreateEvent.InPlayCheckbox).ClickOnIt("IsInPlay");

            // Event DateTime
            ElementVerify.Exist(driver, gmmCreateEvent.EventDatePicker).EnterText("CreateEventPage Date", inplaytime.ToString("dd/MM/yyyy"));
            ElementVerify.Exist(driver, gmmCreateEvent.EventHourDropdown).SelectByText("CreateEventPage Hour", inplaytime.ToString("HH"));
            ElementVerify.Exist(driver, gmmCreateEvent.EventMinuteDropdown).SelectByText("CreateEventPage Minute", inplaytime.ToString("mm"));

            // Ground Type = Neutral(2)
            ElementVerify.Exist(driver, gmmCreateEvent.GroundTypeDropdown).SelectByValue("CreateEventPage GroundType", "2");

            // GameType
            try
            {
                ElementVerify.Exist(driver, gmmCreateEvent.GroundTypeDropdown).SelectByText("CreateEventPage GameType", gametype);
            }
            catch (NoSuchElementException)
            {
                WriteConsole.Yellow("This sport has no GameType");
            }
            #endregion
            #region (3) Save and Get Eevnt ID
            ElementVerify.Exist(driver, gmmCreateEvent.SaveButton).ClickOnIt("Button_Save");
            if (ElementVerify.Exist(driver, gmmCreateEvent.CreateFailMsg, 60).GetAttribute("class") != "hide")
            {
                WriteConsole.DarkRed(ElementVerify.Exist(driver, gmmCreateEvent.CreateFailMsg).Text);
                Report.Log(LogStatus.Fail, "Get Event id", ElementVerify.Exist(driver, gmmCreateEvent.CreateFailMsg).Text);
                Report.PrintScreen(driver);
                throw new Exception("GMM CreateEvent Failed");
            }


            if (ElementVerify.Exist(driver, gmmCreateEvent.CreateSuccessMsg, 60) != null)
            {
                WriteConsole.Green(String.Format("Create Event Successfully! Event id : {0} ({1})", eventid, sport));
                Report.Log(LogStatus.Pass, "Get event id", String.Format("Create Event Successfully! Event id : {0} ({1})", ElementVerify.Exist(driver, gmmCreateEvent.ParentEventId, 60).GetAttribute("Value").Trim(), sport));
                Report.PrintScreen(driver);
                return(ElementVerify.Exist(driver, gmmCreateEvent.ParentEventId, 60).GetAttribute("Value").Trim());     //eventid
            }
            else
            {
                Report.Log(LogStatus.Fail, "Get event id", "Cannot find eventid");
                Report.PrintScreen(driver);
                throw new Exception("GMM CreateEvent Failed");
            }


            Thread.Sleep(2000);
            #endregion
        }
Exemplo n.º 2
0
        public static void CheckReport(string BetNo)
        {
            Report.Case("GMM Wager Enquiry", "Verify wager numbers in Wager Enquiry");
            DateTime eventDayFrom = DateTime.Now.AddDays(-2);
            var      gmmMenu      = new GMMMenu(driver);
            var      wagerEnquiry = new WagerEnquiry(driver);

            #region (1) Access Wager Enquiry
            ElementVerify.Exist(driver, gmmMenu.Report).ClickOnIt("Report");
            ElementVerify.Exist(driver, gmmMenu.WagerEnquiry).ClickOnIt("Wager Enquiry");
            #endregion

            #region (2) Switch to iframe and Select Wager No.
            //Switch to iframe
            driver.SwitchTo().Frame(driver.FindElement(By.TagName("iframe")));
            //Select Wager No.
            ElementVerify.Exist(driver, wagerEnquiry.UserWagerOption).ClickOnIt("User Code or Wager No.");
            ElementVerify.Exist(driver, wagerEnquiry.UserWagerOption).SelectByText("select wager no", "Wager No.");
            #endregion

            #region (3) Pick Event Date From
            if (ElementVerify.Exist(driver, wagerEnquiry.StartDate) != null)
            {
                //Click on calendar icon
                ElementVerify.Exist(driver, wagerEnquiry.StartDate).ClickOnIt("Event Date From");
                ElementVerify.Exist(driver, wagerEnquiry.CalendarPicker);
                ICollection <IWebElement> columns = driver.FindElement(wagerEnquiry.CalendarPicker).FindElements(By.TagName("td"));

                //Click on the number if cell = today's date-2
                foreach (IWebElement cell in columns)
                {
                    if (cell.Text.Equals(eventDayFrom.ToString("dd")))
                    {
                        cell.ClickOnIt("date");
                        break;
                    }
                }
            }
            #endregion

            #region (4) Fetch All Bet Number from TouTou

            char[] delimiterChars = { ',' };
            BetNo = BetNo.Remove(BetNo.Length - 1);        // Reomove the last comma (,)
            string[] wagers = BetNo.Split(delimiterChars);
            foreach (string wager in wagers)
            {
                // Key in wager number in textbox
                Thread.Sleep(2000);
                ElementVerify.Exist(driver, wagerEnquiry.UserWagerValue).EnterText("Wager No.", wager);
                ElementVerify.Exist(driver, wagerEnquiry.SearchButton).ClickOnIt("Search");

                // Wait for data displayed, then fetch wager number
                if (ElementVerify.Exist(driver, wagerEnquiry.WagerToVerify) == null)
                {
                    WriteConsole.DarkRed("Unable to find the wager");
                    continue;
                }

                if (wager == driver.FindElement(wagerEnquiry.WagerToVerify).Text)
                {
                    WriteConsole.Green("Wager Verified");
                }
                else
                {
                    WriteConsole.DarkRed("Unable to find the wager");
                }
            }

            #endregion
            Report.PrintScreen(driver);
        }