public void Scrap(string title) { if (!Helpers.TabIsPresent("About")) { return; } Helpers.Print($"Scrapping -> {title}", ConsoleColor.DarkRed); Helpers.ScrollToBottom(); //_driver.ExecuteScript("scrollBy(0,-document.body.scrollHeight)"); Helpers.ScrollToElement("pagelet_timeline_medley_about"); var tabList = _driver.FindElementsByClassName("_47_-"); GetSpecificOverviewTab(1, tabList, "Work and Education"); GetSpecificOverviewTab(2, tabList, "Places Lived"); GetSpecificOverviewTab(3, tabList, "Contact And Basic Info"); GetSpecificOverviewTab(4, tabList, "Family And Relationships"); GetSpecificOverviewTab(5, tabList, "Details About"); GetSpecificOverviewTab(6, tabList, "Life Events"); //_user.PrintUser(); //GetPlacesLived(); }
public void TestBlankSearchFieldDisplaysTrendingTopics() { OpenURL(); IWebElement searchBox = chromeDriver.FindElementById("sb_form_q"); Actions action = new Actions(chromeDriver); action.MoveToElement(searchBox).Click().Perform(); WebDriverWait webDriverWait = new WebDriverWait(chromeDriver, System.TimeSpan.FromSeconds(5)); webDriverWait.Until(ExpectedConditions.VisibilityOfAllElementsLocatedBy(By.ClassName("sa_as"))); IWebElement trendingHeader = chromeDriver.FindElementByClassName("sa_hd"); IList<IWebElement> trendingTopics = chromeDriver.FindElementsByClassName("sa_sg"); Assert.IsTrue(trendingHeader.Text == "Trending now"); int expectedTrendingTopics = 8; Assert.AreEqual(expectedTrendingTopics, trendingTopics.Count); for(int i = 0; i < trendingTopics.Count; i++) { Assert.IsTrue(trendingTopics[i].Text != ""); } chromeDriver.Quit(); }
private static void RunTests() { var options = new ChromeOptions(); if (UseHeadless) { options.AddArgument("no-sandbox"); options.AddArgument("headless"); } options.AddArgument("window-size=1024x768"); using var service = string.IsNullOrEmpty(ChromeDriverPath) ? ChromeDriverService.CreateDefaultService() : ChromeDriverService.CreateDefaultService(ChromeDriverPath); using var driver = new ChromeDriver(service, options); driver.Url = Url; var index = 0; var currentTimeout = Timeout; do { var pre = driver.FindElementsByTagName("PRE").Skip(index).ToArray(); if (pre.Length > 0) { index += pre.Length; currentTimeout = Timeout; // reset the timeout foreach (var e in pre) { Console.WriteLine(e.Text); } } var resultsElement = driver.FindElementsById("results"); if (resultsElement.Count == 0) { if (driver.FindElementsByClassName("neterror").Count > 0) { var errorCode = driver.FindElementsByClassName("error-code").FirstOrDefault()?.Text; throw new Exception($"There was an error loading the page: {errorCode}"); } Thread.Sleep(500); continue; } var text = resultsElement[0].Text; var bytes = Convert.FromBase64String(text); File.WriteAllBytes(OutputPath, bytes); break; } while (--currentTimeout > 0); if (currentTimeout <= 0) { throw new TimeoutException(); } }
private void SelectFirstFligthOption(String airportCode) { Task.Delay(1000).GetAwaiter().GetResult(); driver.FindElementsByClassName("location-meta") .Single(w => w.Text == airportCode) .Click(); }
public void TestMethod1() { var driver = new ChromeDriver(); driver.Navigate().GoToUrl(PAGE); IWebElement categoryLink = driver.FindElement(By.LinkText(CATEGORYNAME)); if (categoryLink != null) { categoryLink.Click(); IWebElement cellPhoneLink = driver.FindElement(By.LinkText(CELLPHONECATNAME)); if (cellPhoneLink != null) { cellPhoneLink.Click(); IWebElement cellPhoneLinkII = driver.FindElementByClassName(CELLPHONECATCLASSNAME); if (cellPhoneLinkII != null) { cellPhoneLinkII.Click(); var product = driver.FindElementsByClassName(PRODUCTCONTAINERCLASS).Skip(1).FirstOrDefault(); if (product != null) { product.Click(); ParseProduct(driver); var addToCartButton = driver.FindElementById(BUTTONID); if (addToCartButton != null) { addToCartButton.Submit(); driver.Navigate().GoToUrl(CARTURL); var productsInCart = driver.FindElementsByClassName(CARTPRODUCTLINK); if (!productsInCart.Any()) { throw new Exception("Element not found"); } } else { throw new Exception("Element not found"); } } else { throw new Exception("Element not found"); } } else { throw new Exception("Element not found"); } } else { throw new Exception("Element not found"); } } else { throw new Exception("Element not found"); } driver.Close(); }
//method to wait for elements to appear async Task waitForElement(string xPath) { try { await Task.Delay(500); int trys = 0; int count = 0; do { if (xPath.Contains("/")) { var links = driver.FindElementsByXPath(xPath); count = links.Count; } else { var links = driver.FindElementsByClassName(xPath); count = links.Count; } trys++; await Task.Delay(1000); } while (count == 0 && trys < 10); } catch (Exception) { } }
public void GetAllQualifiedTeamsURL() { _driver.Navigate().GoToUrl(this.startURL); System.Threading.Thread.Sleep(1000); var division = _driver.FindElements(By.TagName("option")); for (int i = 0; i < division.Count; i++) { var divisiontemp = _driver.FindElements(By.TagName("option")); var divisionURL = this.startURL + "/session/" + divisiontemp[i].GetAttribute("value").ToString(); _driver.Navigate().GoToUrl(divisionURL); System.Threading.Thread.Sleep(1000); var singleDivisionURL = _driver.FindElementsByClassName("css-k8wt5j"); for (int j = 0; j < singleDivisionURL.Count; j++) { var singleDivisionURLtemp = _driver.FindElementsByClassName("css-k8wt5j"); singleDivisionURLtemp[j].Click(); System.Threading.Thread.Sleep(1000); _driver.Navigate().Back(); } _driver.Navigate().Back(); } }
public static void SelectRestaurant() { wait.Until(driver => driver.FindElement(By.Id("restaurantList")).Displayed); var restaurants = driver.FindElementsByClassName("restaurant"); var restaurant = restaurants[0].FindElement(By.LinkText("Punjabi Curry")); restaurant.Click(); }
private void button1_Click(object sender, EventArgs e) { this.dataGridView1.Rows.Clear(); var stateCode = dict[this.comboBox2.SelectedItem.ToString()]; var webAddressForDetail = $"https://stores.ashleyfurniture.com/Locations?country=US&lat=&lng=&miles=50&search-by=State&address=&state={stateCode}&zip-code="; this.Hide(); try { using (ChromeDriver driver = new ChromeDriver(this.webDriverAddress)) { driver.Navigate().GoToUrl(webAddressForDetail); var addresses = driver.FindElementsByClassName("address"); var postalCodes = driver.FindElementsByClassName("city-postal-code"); var openTimes = driver.FindElementsByClassName("open-hours"); var directions = driver.FindElementsByClassName("directions"); var phoneNums = driver.FindElementsByClassName("phone-number"); var max = getMin(addresses.Count, postalCodes.Count, openTimes.Count, directions.Count, phoneNums.Count); //Console.WriteLine(max); for (int i = 0; i < max; i++) { //Console.WriteLine($"{addresses[i].Text},{postalCodes[i].Text},{openTimes[i].Text},{directions[i].GetAttribute("href").ToString()},{phoneNums[i].Text}"); DataGridViewRow row = new DataGridViewRow(); DataGridViewTextBoxCell addrCell = new DataGridViewTextBoxCell(); addrCell.Value = addresses[i].Text; row.Cells.Add(addrCell); DataGridViewTextBoxCell postCell = new DataGridViewTextBoxCell(); postCell.Value = postalCodes[i].Text; row.Cells.Add(postCell); DataGridViewTextBoxCell openCell = new DataGridViewTextBoxCell(); openCell.Value = openTimes[i].Text; row.Cells.Add(openCell); DataGridViewLinkCell direCell = new DataGridViewLinkCell(); direCell.LinkColor = Color.Blue; direCell.Value = directions[i].GetAttribute("href").ToString(); row.Cells.Add(direCell); DataGridViewTextBoxCell phoneCell = new DataGridViewTextBoxCell(); phoneCell.Value = phoneNums[i].Text; row.Cells.Add(phoneCell); this.dataGridView1.Rows.Add(row); } } } catch (OpenQA.Selenium.WebDriverException ex) { MessageBox.Show(ex.Message, "错误"); } this.Show(); }
private void useragent() { drv = new ChromeDriver(); drv.Navigate().GoToUrl(url); Thread.Sleep(2000); for (int i = 1; i < drv.FindElementsByClassName("useragent").Count; i++) { listBox2.Items.Add(drv.FindElementsByClassName("useragent")[i].Text); } }
public void FindSlot() { var radios = driver.FindElementsByClassName("group-selector--list-item"); foreach (var radio in radios) { ClickAtElement(radio); Thread.Sleep(2000); IterateOverDates(); } }
public async Task Browse(Credential credential, Guid sourceId) { var driver = new ChromeDriver(new ChromeOptions { PageLoadStrategy = PageLoadStrategy.Eager }); WebDriverWait _wait = new WebDriverWait(driver, new TimeSpan(0, 0, 10)); try { driver.Navigate().GoToUrl("https://www.linkedin.com/login"); driver.ExecuteScript("console.log('hi!')"); _wait.Until(d => d.FindElement(By.Id("username"))); driver.FindElement(By.Id("username")).SendKeys(credential.ExternalIdentifier); var passwordTextfield = driver.FindElement(By.Id("password")); passwordTextfield.SendKeys(credential.ExternalSecret); var button = driver.FindElement(By.CssSelector("button[aria-label='Sign in']")); button.Click(); await Task.Delay(1000); driver.Navigate().GoToUrl("https://www.linkedin.com/mynetwork/invite-connect/connections/"); driver.ExecuteScript(RECORD_XHR_BLOBS); _wait.Until(d => d.FindElement(By.CssSelector("[aria-label='Sorting options for connections list']"))); var dropdown = driver.FindElement(By.CssSelector("[aria-label='Sorting options for connections list']")); dropdown.Click(); driver.FindElement(By.CssSelector("[data-control-name='sort_by_recently_added']")).Click(); _wait.Until(ExpectedConditions.ElementExists(By.CssSelector("button[aria-label^='Send message']"))); var connections = driver.FindElementsByClassName("mn-connection-card"); var totalConnections = connections.Count; for (int i = 0; i < connections.Count; i++) { var connection = connections[i]; var card = new ConnectionCard(connection); driver.ExecuteScript("arguments[0].scrollIntoView()", connection); var received = new Events.User { AvatarUrl = card.MugshotUrl, Description = card.Occupation, Id = card.ProfileUrl.AsId <User>(Network.LinkedIn), KnownSince = card.ConnectedDate, Name = card.Name, Network = Network.LinkedIn }; connections = driver.FindElementsByClassName("mn-connection-card"); var responses = driver.ExecuteScript("return window.lresponses;"); driver.ExecuteScript("window.lresponses.clear();"); await SaveResponses(credential, sourceId, responses); } } catch (Exception e) { _logger.LogError(e, "Failed"); } finally { driver?.Quit(); } }
static public List <int> GetItemIds(int bossId) { List <int> list = new List <int>(); driver.Manage().Timeouts().AsynchronousJavaScript = TimeSpan.FromSeconds(15); driver.Url = baseUrl + "npc=" + bossId.ToString(); for (int i = 0; i < driver.FindElementsByClassName(Page.item).Count(); i++) { list.Add(ParseUrlForId(driver.FindElementsByClassName(Page.item)[i].GetAttribute("href"))); } driver.ResetInputState(); return(list); }
public void Successful_Search_With_Correct_Value() { var input = driver.FindElementByClassName("vl_input"); input.SendKeys("днс"); input.Submit(); var companies = driver.FindElementsByClassName("company__header"); var oneCompany = companies.First(); Assert.AreEqual("DNS", oneCompany.Text); Console.WriteLine(oneCompany.Text); }
private async Task ParseId(string id) { //https://www.twitch.tv/roong__/videos?filter=archives&sort=time var url = $"https://www.twitch.tv/{id}/videos?filter=archives&sort=time"; StatusTextBlock.Text = $"Crawling: {id}"; await Task.Delay(100); crawler.Navigate().GoToUrl(url); await Task.Delay(2000); int lastTry = -1; while (true) { if (lastTry == crawler.FindElementsByClassName("preview-card-thumbnail__image").Count) { break; } lastTry = crawler.FindElementsByClassName("preview-card-thumbnail__image").Count; ((IJavaScriptExecutor)crawler).ExecuteScript("window.scrollTo(0, document.body.scrollHeight)"); await Task.Delay(1000); } foreach (var node in crawler.FindElementsByClassName("preview-card-thumbnail__image")) { var image = node.FindElement(By.ClassName("tw-image")); var title = image.GetAttribute("title"); var src = image.GetAttribute("src"); var alt = image.GetAttribute("alt"); if (src.Contains("processing")) { continue; } Debug.WriteLine($"{title} / {src}"); var data = new VODData(); data.BroadcastDate = title; data.StreamerId = id; data.BroadcastTitle = alt; data.ThumbnailURL = src; var root = Path.Combine(PathTextBox.Text, data.StreamerId); var fn = Path.Combine(root, data.OutputFilename); data.DownloadIt = !File.Exists(fn); VODDatas.Add(data); } StatusTextBlock.Text = $"Crawled: {id}"; }
public void NineBoardGameFlow() { var boards = _webDriver.FindElementsByClassName("board"); Assert.Equal(9, boards.Count); var tiles = _webDriver.FindElementsByClassName("tile"); Assert.Equal(81, tiles.Count); var gameOver = _webDriver.FindElementsByClassName("game-over"); Assert.Empty(gameOver); PlayInPosition(0, 0, 1, 0, "X"); // Tries to play in wrong board FailToPlayInPosition(0, 0, 1, 1); PlayInPosition(1, 0, 0, 0, "O"); PlayInPosition(0, 0, 1, 1, "X"); PlayInPosition(1, 1, 0, 0, "O"); PlayInPosition(0, 0, 1, 2, "X"); PlayInPosition(1, 2, 0, 1, "O"); // Tries to play in complete board FailToPlayInPosition(0, 0, 2, 2); // Succeeds playing in any board PlayInPosition(0, 1, 1, 0, "X"); PlayInPosition(1, 0, 0, 1, "O"); PlayInPosition(0, 1, 1, 1, "X"); PlayInPosition(1, 1, 0, 1, "O"); PlayInPosition(0, 1, 1, 2, "X"); PlayInPosition(1, 2, 0, 2, "O"); PlayInPosition(0, 2, 2, 0, "X"); PlayInPosition(2, 0, 0, 2, "O"); PlayInPosition(0, 2, 2, 1, "X"); PlayInPosition(2, 1, 0, 2, "O"); PlayInPosition(0, 2, 2, 2, "X"); gameOver = _webDriver.FindElementsByClassName("game-over"); Assert.Equal(1, gameOver.Count); Assert.Contains("Game Over. CROSS has won.", gameOver.First().Text); FailToPlayInPosition(2, 2, 2, 2); }
int i = 0; // 현재 배열 위치 private void btnSearch_Click(object sender, EventArgs e) { string strUrl = "https://www.google.com/search?q=" + txtSearch.Text + "&source=lnms&tbm=isch"; _driver = new ChromeDriver(_driverService, _options); _driver.Navigate().GoToUrl(strUrl); _driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(10); _driver.ExecuteScript("window.scrollBy(0,10000)"); // 창을 띄우고 스크롤 진행(아래 스크롤 한거) lstSrc = new List <string>(); foreach (IWebElement item in _driver.FindElementsByClassName("rg_i")) { if (item.GetAttribute("src") != null) { lstSrc.Add(item.GetAttribute("src")); } } lblTotal.Text = string.Format("/ {0}", lstSrc.Count); this.Invoke(new Action(delegate() { foreach (string strsrc in lstSrc) { i++; GetMapImage(lstSrc[i]); txtGo.Text = i.ToString(); Refresh(); Thread.Sleep(50); } })); }
public void TestMethod_02() { _driver.Url = "http://*****:*****@gmail.com"); IWebElement webElementPassword = _driver.FindElementById("Password"); webElementPassword.SendKeys("123456"); IWebElement elementNext = _driver.FindElementByClassName("btn"); elementNext.Click(); System.Threading.Thread.Sleep(1000); IList <IWebElement> webElementsLinks = _driver.FindElementsByClassName("nav-link"); Assert.AreEqual(3, webElementsLinks.Count); Assert.AreEqual("List", webElementsLinks[0].Text); Assert.AreEqual("Create", webElementsLinks[1].Text); Assert.AreEqual("Logout [email protected]", webElementsLinks[2].Text); System.Threading.Thread.Sleep(2000); }
private void DownloadSongFromYoutube(ChromeDriver driver, string songName) { if (FromYoutubeDownloads == null) { FromYoutubeDownloads = new List <string>(); } FromYoutubeDownloads.Add(songName); var url = $"https://www.youtube.com.br/results?search_query={GetYoutubeQueryString(songName)}"; driver.Navigate().GoToUrl(url); driver.WaitForPageToLoad(); driver.WaitForElementToBeDisplayed(By.CssSelector("a#video-title.yt-simple-endpoint.style-scope.ytd-video-renderer")); var contents = driver.FindElements(By.CssSelector("a#video-title.yt-simple-endpoint.style-scope.ytd-video-renderer")); var link = contents.FirstOrDefault()?.GetAttribute("href"); var videoId = link?.Split("v=")?.LastOrDefault()?.Trim(); driver.Navigate().GoToUrl($"https://www.yt-download.org/pt/@api/button/mp3/{videoId}"); driver.WaitForPageToLoad(); Count++; Console.WriteLine($"Downloading song {Count}/{Total} '{songName}' from Youtube. This may delay the processing\n"); driver.WaitForElementToBeDisplayed(By.ClassName("download-result"), TimeSpan.FromMinutes(5)); var elDownload = driver.FindElementsByClassName("link").FirstOrDefault(); elDownload?.Click(); FromYoutubeDownloads.Remove(songName); }
// Open tab public string BackTracking(ChromeDriver chrome, int n, int MaxN, string ScreenShotPath) { string Result = ""; try { var Arr = chrome.FindElementsByClassName("tablv-" + n.ToString()); foreach (var sItem in Arr) { if (sItem.Text != "" && sItem.Displayed && sItem.Location.X > 0 && sItem.Location.Y > 0) { sItem.Click(); Thread.Sleep(5000); Result += VerifyError(chrome, ScreenShotPath); if (n < MaxN) { BackTracking(chrome, n + 1, MaxN, ScreenShotPath); } } } return(Result); } catch { return(Result); } }
public CostSearcher(string subject, ChromeDriver driver) { mCurrentCost = -1; mDriver = driver; var subjectField = mDriver.FindElementById("stock_items"); var searchButton = mDriver.FindElementByClassName("snb_search_btn"); subjectField.SendKeys(subject); searchButton.Click(); Thread.Sleep(500); var currTitleField = mDriver.FindElementsByClassName("tit"); string strTempSubject; bool bIsNotFound = true; if (0 < currTitleField.Count) { foreach (var subjectsItem in currTitleField) { strTempSubject = subjectsItem.Text; bIsNotFound = (strTempSubject != subject); if (!bIsNotFound) { var link = subjectsItem.FindElement(By.TagName("a")); link.Click(); break; } } } mStrUrl = mDriver.Url; SearchCost(); }
// Open Expander public string OpenExpander(ChromeDriver chrome, string ScreenShotPath) { string Result = ""; try { var ExpanderList = chrome.FindElementsByClassName("btn-outline-link"); long MaxHeight = chrome.Manage().Window.Size.Height - 500; long temp = MaxHeight; foreach (var sItem in ExpanderList) { IJavaScriptExecutor js = (IJavaScriptExecutor)chrome; if (sItem.Location.Y >= MaxHeight) { js.ExecuteScript($"window.scrollBy(0, {sItem.Location.Y - 150});"); MaxHeight += temp; } Thread.Sleep(1000); sItem.Click(); Thread.Sleep(1500); Result += VerifyError(chrome, ScreenShotPath); sItem.Click(); Thread.Sleep(1500); } } catch { } return(Result); }
private List <TabelaBrasileirao> BuscarTabelaBrasileirao(ChromeDriver driver) { try { driver.Navigate().GoToUrl("https://globoesporte.globo.com/futebol/brasileirao-serie-a/"); Thread.Sleep(5000); var rowTables = driver.FindElementsByClassName("classificacao__tabela--linha"); var tabelaBrasileiro = new List <TabelaBrasileirao>(); if (rowTables != null) { foreach (var row in rowTables.Take(20)) { var posicao = row.FindElements(By.ClassName("classificacao__equipes--posicao")).FirstOrDefault().Text; var time = row.FindElements(By.ClassName("classificacao__equipes--time")).FirstOrDefault().Text; tabelaBrasileiro.Add(new TabelaBrasileirao() { Posicao = Convert.ToInt32(posicao), Clube = time }); } } return(tabelaBrasileiro); } catch (Exception ex) { throw ex; } }
public static string DownloadString(string address) { string sourcecode = ""; //init diever using (ChromeDriver driver = new ChromeDriver()) { //set the url string payloadurl = address; driver.Navigate().GoToUrl(payloadurl); //set up wait timer WebDriverWait wait = new WebDriverWait(driver, System.TimeSpan.FromSeconds(120)); //userDetails wait.Until(drivermy => driver.FindElement(By.ClassName("userDetails")) ); //dl string var src = driver.FindElementsByClassName("price"); sourcecode = src[1].GetAttribute("innerHTML"); driver.Close(); } return(sourcecode); }
public static bool IsTileAvailable(ChromeDriver driver, string tileName) { IReadOnlyCollection <IWebElement> tiles = driver.FindElementsByClassName("wgt-static__title-text"); var isVisible = tiles.Any(x => x.Text.Equals(tileName)); return(isVisible); }
private void Ft_Id_Pic(ChromeDriver chrome, int col, bool flag) { int i; List <string> list_id = new List <string>(); List <IWebElement> webElements = (from item in chrome.FindElementsByClassName("feed_row") where item.Displayed select item).ToList(); i = 0; while (i < col) { i = Ft_Record_Fail_Pic(webElements, list_id, col, i, flag); webElements = (from item in chrome.FindElementsByClassName("feed_row") where item.Displayed select item).ToList(); } }
public void AddCheckCommentBlogTest() { string comment = "Nice post! " + RandomString(5); string author = "Mateusz M."; string email = GenerateEmail(); string url = "http://mati.automatyzuje.pl"; browser.Navigate().GoToUrl("http://automatyzacja.benedykt.net"); // przejscie do komentarza postu var commentLink = browser.FindElementByClassName("comments-link"); commentLink.Click(); //dodanie komentarza var commentTextBox = browser.FindElementById("comment"); var authorTextBox = browser.FindElementById("author"); var emailTextBox = browser.FindElementById("email"); var urlTextBox = browser.FindElementById("url"); var addCommentButton = browser.FindElementById("submit"); commentTextBox.Click(); commentTextBox.SendKeys(comment); authorTextBox.SendKeys(author); emailTextBox.SendKeys(email); urlTextBox.SendKeys(url); addCommentButton.Click(); var addedCommentsToVerify = browser.FindElementsByClassName("comment-content"); //bool expected = false; var com = addedCommentsToVerify.Where(c => c.FindElement(By.CssSelector("p")).Text == comment); Assert.Single(com); //foreach (var commentA in addedCommentsToVerify) //{ // if (commentA.FindElement(By.CssSelector("p")).Text == comment) // expected = true; // break; //} //Assert.True(expected); }
static void Main(string[] args) { var driver = new ChromeDriver(); driver.Navigate().GoToUrl(PAGE); IWebElement categoryLink = driver.FindElement(By.LinkText(CATEGORYNAME)); if (categoryLink != null) { categoryLink.Click(); IWebElement cellPhoneLink = driver.FindElement(By.LinkText(CELLPHONECATNAME)); if (cellPhoneLink != null) { cellPhoneLink.Click(); IWebElement cellPhoneLinkII = driver.FindElementByClassName(CELLPHONECATCLASSNAME); if (cellPhoneLinkII != null) { cellPhoneLinkII.Click(); var product = driver.FindElementsByClassName(PRODUCTCONTAINERCLASS).Skip(1).FirstOrDefault(); if (product != null) { product.Click(); ParseProduct(driver); var addToCartButton = driver.FindElementById(BUTTONID); if (addToCartButton != null) { addToCartButton.Submit(); driver.Navigate().GoToUrl(CARTURL); var productsInCart = driver.FindElementsByClassName(CARTPRODUCTLINK); if (!productsInCart.Any()) { Console.WriteLine("Product has not been added to the cart"); } else { Console.WriteLine("Product has been added to the cart"); } Console.Read(); } } } } } }
private void getImage(ChromeDriver chrome, int a) { var img = chrome.FindElementsByClassName("lazy"); for (int i = 0; i < img.Count; i++) { DowloadImage(img[i].GetAttribute("src"), i); } }
public void ThenIValidateThatTheCheckboxWithTheClassHasRole(string className, string checkboxText) { ChromeDriver driver = SeleiumDriver; var checkboxes = driver.FindElementsByClassName(className); var adminCheckbox = checkboxes.Where(e => e.GetAttribute(ValueAttributeInInput) == checkboxText).First(); Assert.IsTrue(adminCheckbox.Selected); }