I've been working on a project using selenium 2 webdriver.

Took me a while but finally got it working inside iframes of a web page.

Thing is, I searched a lot and seen many examples but none that looked like what I ended up with, looks a bit weird and hacky.

My question is if anyone who uses selenium can see a better and cleaner way of doing this.

namespace mySeleniumChrome
    class Program

        static void Main(string[] args)
            String pathtodriverfolder = @"path to selenium chromedriver.exe";

            ChromeDriverService driverService = ChromeDriverService.CreateDefaultService(pathtodriverfolder);
            driverService.HideCommandPromptWindow = true;

            ChromeOptions options = new ChromeOptions();

            IWebDriver driver = new ChromeDriver(driverService, options);


            IWebDriver frame = driver.SwitchTo().Frame("view");

            IWebElement frame2 = frame.FindElement(By.TagName("iframe"));


            IWebElement searchbox = frame.FindElement(By.Id("gsc-i-id1"));




Just looking for some advice or pointers.

Thank you for taking the time to read.