public void LhycRegatta() { using var driver = new ChromeDriver(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)); driver.Navigate().GoToUrl(configuration.BaseUrl); //if logged in, log out. var logout = driver.FindElementsByLinkText("Log out"); var clubSelector = new SelectElement(driver.FindElement(By.Id("clubSelect"))); //javascript should navigate automatically. clubSelector.SelectByText("Lake Harriet Yacht Club"); var currentElement = driver.WaitUntilClickable(By.PartialLinkText("LHYC")); Assert.Equal(configuration.BaseUrl + "/LHYC", driver.Url); Thread.Sleep(300); currentElement = driver.WaitUntilClickable(By.LinkText("Regattas")); currentElement.Click(); currentElement = driver.WaitUntilClickable(By.CssSelector("a[href*= '/2020/DieHard']")); currentElement.Click(); currentElement = driver.WaitUntilVisible(By.XPath("//*[contains(.,'Grosch, Ryan')]")); //*[@id="regattalink_6f2e4bfe-8d0d-41b5-485e-08d732752bb6"] Assert.Contains("Grosch", currentElement.Text); }
public void LhycSeries() { using var driver = new ChromeDriver(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)); driver.Navigate().GoToUrl(configuration.BaseUrl); //if logged in, log out. var logout = driver.FindElementsByLinkText("Log out"); var clubSelector = new SelectElement(driver.FindElement(By.Id("clubSelect"))); //javascript should navigate automatically. clubSelector.SelectByText("Lake Harriet Yacht Club"); var currentElement = driver.WaitUntilClickable(By.PartialLinkText("LHYC")); Assert.Equal(configuration.BaseUrl + "/LHYC", driver.Url); Thread.Sleep(300); currentElement = driver.WaitUntilClickable(By.LinkText("Series")); currentElement.Click(); Thread.Sleep(300); currentElement = driver.WaitUntilClickable(By.CssSelector("a[href*='LHYC/2019/MC Season Champ']")); currentElement.Click(); driver.WaitUntilVisible(By.CssSelector("table.table")); var rows = driver.FindElements(By.CssSelector("tr")); Assert.True(rows.Count > 25, "At least 25 rows expected in 2019 season champ results"); var headers = driver.FindElements(By.CssSelector("thead th")); Assert.True(headers.Count > 25, "At least 25 headers expected"); }
public void LhycRace() { using var driver = new ChromeDriver(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)); driver.Navigate().GoToUrl(configuration.BaseUrl); //if logged in, log out. var logout = driver.FindElementsByLinkText("Log out"); var clubSelector = new SelectElement(driver.FindElement(By.Id("clubSelect"))); //javascript should navigate automatically. clubSelector.SelectByText("Lake Harriet Yacht Club"); var currentElement = driver.WaitUntilClickable(By.PartialLinkText("LHYC")); Assert.Equal(configuration.BaseUrl + "/LHYC", driver.Url); Thread.Sleep(300); currentElement = driver.WaitUntilClickable(By.LinkText("Races")); currentElement.Click(); currentElement = driver.FindElementByXPath("//*[@id='racelink_5e191bc2-04aa-4c5a-8a19-76b1484a95bb']"); currentElement.Click(); // Relying on these to throw exception if not found. driver.FindElement(By.XPath("//*[contains(.,'Grosch, Ryan')]")); driver.FindElement(By.XPath("//*[contains(.,'Black Cat')]")); }
public void FillOutClubRequest_Load() { using var driver = new ChromeDriver(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)); driver.Navigate().GoToUrl(configuration.BaseUrl); //if logged in, log out. var logout = driver.FindElementsByLinkText("Log out"); if (logout.Count > 0) { logout[0].Click(); } driver.FindElement(By.LinkText("Try it out")).Click(); driver.FindElement(By.Id("ClubName")).Click(); driver.FindElement(By.Id("ClubName")).SendKeys("asdf"); driver.FindElement(By.Id("ClubInitials")).Click(); driver.FindElement(By.Id("ClubInitials")).SendKeys("ASDF"); driver.FindElement(By.Id("ClubLocation")).SendKeys("somewhere"); driver.FindElement(By.Id("ClubWebsite")).SendKeys("http://www.google.com"); driver.FindElement(By.Id("ContactName")).SendKeys("Jamie Fraser Test"); driver.FindElement(By.Id("ContactEmail")).SendKeys("*****@*****.**"); driver.FindElement(By.Id("Classes")).SendKeys("MC "); driver.FindElement(By.Id("Comments")).SendKeys("Nothing"); driver.FindElement(By.CssSelector(".btn-success")).Click(); driver.FindElement(By.XPath("//h1[contains(.,'Club Created')]")); }
public void AboutAndNews_Load() { using var driver = new ChromeDriver(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)); driver.Navigate().GoToUrl(configuration.BaseUrl); //if logged in, log out. var logout = driver.FindElementsByLinkText("Log out"); if (logout.Count > 0) { logout[0].Click(); } var currentElement = driver.WaitUntilClickable(By.LinkText("About")); currentElement.Click(); // Relying on this to throw exception if not found. driver.FindElement(By.XPath("//h1[contains(.,'kept simple')]")); currentElement = driver.WaitUntilClickable(By.LinkText("News")); currentElement.Click(); // Relying on this to throw exception if not found. driver.FindElement(By.XPath("//h5[contains(.,'To the cloud')]")); }
public void ThenICanNotFindBookWithName(string bookName) { ChromeDriver driver = SeleiumDriver; var actual = driver.FindElementsByLinkText(bookName); CollectionAssert.IsEmpty(actual); }
public static void ClickOnTile(ChromeDriver driver, int elementIndex) { IReadOnlyCollection <IWebElement> buttons = driver.FindElementsByLinkText("Launch"); var button = buttons.ElementAt(elementIndex); button.Click(); }
public static string[] GetListIndexMatchinData(DateTime dataTime)//получение индексов матчей в определенную дату { if (dataTime.Year < MinYearoftheGame) { throw DataExeption.DataProcessingExeptions.ErrorWriteData("Invalid date"); } var ChromeService = ChromeDriverService.CreateDefaultService(System.IO.Directory.GetCurrentDirectory()); ChromeService.HideCommandPromptWindow = true; //скрываем консоль веб драйвера var WebBrowser = new ChromeDriver(ChromeService); //Иницализация веб драйвера Chrome string url = $"http://stats.nba.com/scores/{dataTime.Month.ToString()}/{dataTime.Day.ToString()}/{dataTime.Year.ToString()}"; WebBrowser.Navigate().GoToUrl(url); IEnumerator <IWebElement> ListFindingElementsIndex, ListFindingElementsMatch; if (dataTime.Date.CompareTo(DateTime.Now.Date) < 0) { ListFindingElementsIndex = WebBrowser.FindElementsByLinkText("Box Score").GetEnumerator(); ListFindingElementsMatch = WebBrowser.FindElements(By.CssSelector("div.linescores-container span.team-name")).GetEnumerator(); } else { WebBrowser.Quit(); ChromeService.Dispose(); WebBrowser.Dispose(); throw DataExeption.DataProcessingExeptions.ErrorWriteData("Invalid date"); } List <string> ListMatch = new List <string>(); ListFindingElementsIndex.Reset(); ListFindingElementsMatch.Reset(); while (ListFindingElementsMatch.MoveNext()) { string temporary = ListFindingElementsMatch.Current.Text; if (!ListFindingElementsMatch.MoveNext()) { throw DataExeption.DataProcessingExeptions.ErrorWriteData("Could not read data from the site"); } temporary += '\t' + ListFindingElementsMatch.Current.Text; if (!ListFindingElementsIndex.MoveNext()) { throw DataExeption.DataProcessingExeptions.ErrorWriteData("Could not read data from the site"); } temporary += '\t' + Default.TextWorker.Repalase(ListFindingElementsIndex.Current.GetAttribute("href"), new string[] { "http://stats.nba.com/game/", "/" }, ""); ListMatch.Add(temporary); } WebBrowser.Quit(); ListFindingElementsIndex.Dispose(); ListFindingElementsMatch.Dispose(); WebBrowser.Dispose(); ChromeService.Dispose(); return(ListMatch.ToArray()); }
public void HomePage_HasDropdown() { using var driver = new ChromeDriver(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)); driver.Navigate().GoToUrl(configuration.BaseUrl); //if logged in, log out. var logout = driver.FindElementsByLinkText("Log out"); if (logout.Count > 0) { logout[0].Click(); } var clubSelector = new SelectElement(driver.FindElement(By.Id("clubSelect"))); Assert.NotNull(clubSelector); }
public void ShouldCheckLinksDomain() { var driver = new ChromeDriver(); driver.Navigate().GoToUrl(testUrl); IReadOnlyCollection <IWebElement> links = null; #region TEST CODE links = driver.FindElementsByLinkText("Details"); #endregion Assert.NotNull(links); Assert.AreEqual(links.Count, 6); Assert.IsTrue(links.All(x => x.TagName == "a")); Assert.IsTrue(links.All(x => x.GetAttribute("href").StartsWith("https://www.terrypratchettbooks.com"))); driver.Quit(); }