Carlos Iyu Carlos Iyu - 3 months ago 14
C# Question

C#: Selenium - Element is not a frame element : FRAMESET

Im trying to acess and populate some EDIT with selenium, but i got error...

I need to enter in frameset.

HTML :

<iframe src="NIB_MainFrame.asp" name="Principal" style="height:100%;width:100%;border:0;padding:0;border:0;margin:0;display:block;overflow-y:hidden" __idm_frm__="467"></iframe>
<frameset id="frmSet" rows="55,0,*,24" border="0" framespacing="0" frameborder="no">
<frame noresize="noresize" scrolling="no" name="Header" src="NIB_Header.asp" __idm_frm__="472">
<frame noresize="noresize" scrolling="no" name="Menu" src="Blank.htm" __idm_frm__="473">
<frame noresize="noresize" scrolling="auto" name="Corpo" src="NIB_Pre_Bridge.asp?txtAgencia=4346&amp;txtConta=014543708" __idm_frm__="474">
<frame noresize="noresize" scrolling="no" name="Rodape" src="NIB_Rodape.asp" __idm_frm__="475">
</frameset>
</iframe>


C#

driver.SwitchTo().Frame(0);
IWebElement detailFrame = driver.FindElement(By.XPath("//*[@id='frmSet']"));
driver.SwitchTo().Frame(detailFrame);


ERROR :


OpenQA.Selenium.NoSuchFrameException was unhandled
HResult=-2146233088
Message=Element is not a frame element: FRAMESET
Source=WebDriver

Answer

You should try below

driver.SwitchTo().Frame("Principal");
driver.SwitchTo().Frame("Header");

No need to switch frameSet. you can directally switch to Header frame