public static void SwitchTabs(string teamname) { Found = false; Base.homewindow = webDriver.CurrentWindowHandle; Console.Clear(); Console.WriteLine("Trwa wyszukiwanie druzyny: " + teamname); Actions act = new Actions(webDriver); string[] tabs = { "li0", "li1", "li2" }; for (int i = 0; i <= 2; i++) { if (!Found) { IWebElement tab_all = Base.IsVisible(webDriver, By.CssSelector("div#fscon ul li." + tabs[i])); act.MoveToElement(tab_all).Click().Build().Perform(); FindInTabSwitch(teamname); } } if (!Found) { Console.WriteLine("Nie znaleziono druzyny."); Base.Getter(); } }
static void Main(string[] args) { string url = "http://flashscore.pl/"; Console.WriteLine("1 - Pilka nozna\n2 - Tenis\n3 - Hokej\n4 - Koszykówka\n5 - Siatkówka\n6 - Baseball"); Console.Write("Podaj numer lub nazwe dyscypliny: "); string sportsname = Console.ReadLine(); switch (sportsname) { case "1": sportsname = "Piłka nożna"; break; case "2": sportsname = "Tenis"; break; case "3": sportsname = "Hokej"; break; case "4": sportsname = "Koszykówka"; break; case "5": sportsname = "Siatkówka"; break; case "6": sportsname = "Baseball"; break; default: break; } Console.Write("Podaj nazwe druzyny: "); string teamname = Console.ReadLine(); if (teamname == "quit") { Base.CloseEverything(); } else { Driver.Goto(url); Base.CloseCookies(); Homepage.SwitchSports(sportsname); Base.Getter(teamname); } }
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 { } }
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()); } }