0

I am trying to get every title from every post into text form. Every text is contained in a h3 tag and I was trying to get the title that way to no avail.

Here is what I have so far.

 public void runBrowser()
    {
        IWebDriver driver = new ChromeDriver();
        driver.Url = "https://www.reddit.com/r/nintendoSwitch/";

       string finalText = driver.FindElement(By.TagName("h3")).Text;

        Console.WriteLine(final);
    }

I have tried using Xpath but also was met with no results. If anyone could help that would be great

1 Answers1

0

You page might not fully loaded yet when you try find an element. Please follow answers in this thread to wait for the text. Also that is possible that there are several h3 elements, and first one is empty, so find all h3 elements on the page instead of first one.

fenixil
  • 2,106
  • 7
  • 13