Created
August 4, 2022 05:21
-
-
Save bharathmuddada/a5705b57c27fb07d748ddbc73eedcdea to your computer and use it in GitHub Desktop.
Selenium C# program to fetch all the links from the google search results.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class GoogleResults { | |
public static void Main(string[] args) { | |
new DriverManager().SetUpDriver(new ChromeConfig()); | |
var driver = new ChromeDriver(); | |
driver.Navigate().GoToUrl("https://www.google.com/"); | |
driver.Manage().Window.Maximize(); | |
var search = driver.FindElement(By.Name("q")); | |
search.SendKeys("Selenium"); | |
search.Submit(); | |
var alllinks = | |
driver.FindElements(By.TagName("a")); | |
Console.WriteLine(alllinks.Count); | |
foreach (var link in alllinks) { | |
Console.WriteLine(link.GetAttribute("href")); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment