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

2019-07-18 17:51发布

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

标签: c# selenium
2条回答
【Aperson】
2楼-- · 2019-07-18 18:34

You should try below

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

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

查看更多
手持菜刀,她持情操
3楼-- · 2019-07-18 18:35

You should try the following change and it should work. Change

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

to

IWebElement detailFrame = driver.FindElement(By.XPath(".//frameset[@id='frmSet']"));
查看更多
登录 后发表回答