So right now I\'m trying to figure out how I can switch focus to a frame in Selenium 2 when the frame has no name or id? For a named frame I do:
driver.Switc
You can just give the id of your iframe instead of iframe-name.
Please see my below example, it worked for me.
In the example I am switching to one iframe in my page and clicking on the element in that iframe, which is "worksheet0" .
Use the code :
driver.switchTo().frame("topframe");
WebElement worksheet0 = driver.findElement(By.xpath("//*@id='reportSelect:Worksheet_lbl']")); worksheet0.click();
The HTMLof the iframe :
< iframe id="topframe" height="83px" frameborder="0" width="100%" scrolling="NO" '1331808552380'"="" +="" src="initialize.do?init=header&cacheBuster=" name="topframe" marginheight="0" marginwidth="0">