I have HTML code like this for an iframe:
Did you try (java code):
driver.switchTo().frame("iFrameName");
driver.findElement(By.id("formOne")).click();
driver.findElement(By.id("formOne")).sendKeys("abc");
SwitchTo()
method takes index, name or frame element, so you can try use name or frame element.
//find the frame by class/title/type/source
IWebElement detailFrame = driver.FindElement(By.XPath("//iframe[@class='class1']"));
driver.SwitchTo().Frame(detailFrame);
//alternatively, find the frame first, then use GetAttribute() to get frame name
IWebElement detailFrame = driver.FindElement(By.XPath("//iframe[@class='class1']"));
driver.SwitchTo().Frame(detailFrame.GetAttribute("name"));
//you are now in iframe "Details", then find the elements you want in the frame now
IWebElement foo = driver.FindElement(By.Id("foo"));
foo.Click();
//switch back to main frame
driver.SwitchTo().DefaultContent();