Esempio n. 1
0
        private static void FindInTabSwitch(string teamname)
        {
            Found      = false;
            homewindow = webDriver.CurrentWindowHandle;
            Actions             act  = new Actions(webDriver);
            IList <IWebElement> team = Base.AreVisible(webDriver, By.CssSelector("div#fs div table tbody tr"));

            if (team != null)
            {
                foreach (IWebElement t in team)
                {
                    if (t.Text.Contains(teamname))
                    {
                        act.MoveToElement(t).Click().Build().Perform();
                        Found = true;
                        break;
                    }
                }
            }
            if (Found)
            {
                Details.GetDetails();
            }
            else
            {
            }
        }
Esempio n. 2
0
        public static void SwitchSports(string sport)
        {
            bool found_sport         = false;
            IList <IWebElement> rows = Base.AreVisible(webDriver, By.CssSelector("#menu ul li"));

            try
            {
                Actions act = new Actions(webDriver);
                for (int i = 0; i <= 7; i++)
                {
                    if (rows[i].Text.Contains(sport.ToUpper()))
                    {
                        act.MoveToElement(rows[i]).Click().Build().Perform();
                        found_sport = true;
                    }
                }
                if (!found_sport)
                {
                    IWebElement moresports = Base.IsVisible(webDriver, By.CssSelector("#menu ul li.minority"));
                    act.MoveToElement(moresports).Click().Build().Perform();
                    IList <IWebElement> more = moresports.FindElements(By.CssSelector("ul#menumin li"));
                    for (int i = 0; i <= more.Count; i++)
                    {
                        if (rows[i].Text.Contains(sport.ToUpper()))
                        {
                            act.MoveToElement(rows[i]).Click().Build().Perform();
                            found_sport = true;
                        }
                    }
                }
                if (!found_sport)
                {
                    Console.WriteLine("Nie znaleziono dyscypliny.");
                    Base.Getter();
                }
            }
            catch { }
        }
Esempio n. 3
0
        public static void GetDetails()
        {
            WebDriverWait wait = new WebDriverWait(webDriver, TimeSpan.FromSeconds(15));

            wait.Until(driver1 => ((IJavaScriptExecutor)webDriver).ExecuteScript("return document.readyState").Equals("complete"));

            webDriver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(15));
            webDriver.Manage().Timeouts().SetPageLoadTimeout(TimeSpan.FromSeconds(15));

            try
            {
                webDriver.SwitchTo().Window(webDriver.WindowHandles[1].ToString());
                string current_window = webDriver.CurrentWindowHandle;

                IWebElement state = Base.IsVisible(webDriver, By.ClassName("mstat"));
                if (state.Text.Length < 1)
                {
                    Console.WriteLine("Mecz sie jeszcze nie zaczal.\n");
                    webDriver.Close();
                    Base.Refresh();
                    Base.Getter();
                }
                else
                {
                    IWebElement home   = Base.IsVisible(webDriver, By.ClassName("tname-home"));
                    IWebElement result = Base.IsVisible(webDriver, By.ClassName("current-result"));
                    IWebElement away   = Base.IsVisible(webDriver, By.ClassName("tname-away"));

                    Console.Clear();
                    Console.WriteLine(string.Format("{0} - {1} {2} ({3})\n", home.Text, away.Text, result.Text, state.Text));

                    wait.Until(driver1 => ((IJavaScriptExecutor)webDriver).ExecuteScript("return document.readyState").Equals("complete"));
                    wait.Until(ExpectedConditions.VisibilityOfAllElementsLocatedBy(By.CssSelector("table#parts tr")));

                    IList <IWebElement> rows = Base.AreVisible(webDriver, By.CssSelector("table#parts tr"));
                    if (rows.Count > 0)
                    {
                        for (int i = 0; i <= rows.Count - 1; i++)
                        {
                            if (rows[i].Text.Length > 3)
                            {
                                Console.WriteLine(rows[i].Text.Replace("\r\n", " "));
                                //Console.WriteLine(CheckTime(rows.ElementAt(i)) + AddEvent(rows.ElementAt(i)));
                            }
                        }
                    }
                    else
                    {
                        Console.WriteLine("Blad: nie pobralo wydarzen.");
                    }
                    Console.WriteLine("___________________________");
                    webDriver.Close();
                    Base.Refresh();
                    Base.Getter();
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("Details error " + ex.Message.ToString());
            }
        }