Suzie999 245 Coding Hobbyist

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();
            options.AddArguments("test-type");

            IWebDriver driver = new ChromeDriver(driverService, options);

                        driver.Navigate().GoToUrl("http://www.w3schools.com/tags/tryit.asp?filename=tryhtml_iframe");

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

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

            frame.SwitchTo().Frame(frame2);

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

            searchbox.SendKeys("testing");

            frame.Dispose();
            driver.Dispose();

        }
    }
}

Just looking for some advice or pointers.

Thank you for taking the time to read.