Selenium switchTo框架使用Frameset

时间:2015-08-10 09:56:02

标签: selenium

<frameset border="0" rows="25,*" frameSpacing="0" frameBorder="0" onbeforeunload="doUnload()" onunload="doUnload()" onkeydown="fn_KeyDown(event)">
    <frame name="link" scrolling="no" src="Links.aspx?FromWhere=DB" marginwidth="0" marginheight="0" BORDER="0" target="_self">
    <script >
    alert('');</script>

                <frame id="Sub" src="../Home/Home.aspx?FromWhere=DB" scrolling="Yes"  name="Sub" >

</frameset>

如何在此处切换到帧并在selenium中执行操作?

1 个答案:

答案 0 :(得分:0)

如果您想切换到第一帧driver.switchTo().frame(driver.findElement(By.cssSelector("frame[name='link']")));

如果要切换到名为“Sub”的第二帧

driver.switchTo().frame(driver.findElement(By.cssSelector("frame[name='Sub']")));

driver.switchTo().frame(driver.findElement(By.cssSelector("frame#Sub")));