硒2 - 焦点切换到不具有名称/ ID帧 [英] Selenium 2 - Switching focus to a frame that has no name/id
问题描述
所以现在我想弄清楚我怎么能在2硒焦点切换到一帧时,帧没有名称或ID?对于命名框架我做的:
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.SwitchTo().Frame(FrameName);
但什么是没有名字?有没有人有这样的经历。
but what is there is no name? Has anyone had experience with this?
推荐答案
driver.switchTo.frame()是的重载接受一个框架名称或整数。这int是可用的帧0的索引。第一帧是0,第二个1等。
driver.switchTo.frame() is overloaded to accept a frame name or an integer. This int is a 0 based index of the frames available. The first frame would be 0, the second 1 and so on.
我刚刚运行使用Java绑定和Firefox针对此HTML页面一个真正的快速测试。
I've just run a really quick test using the java binding and Firefox against this HTML page.
<html>
<frameset rows="50%,50%">
<frame src="frame_a.htm" />
<frame src="frame_b.htm" />
</frameset>
</html>
我能够成功使用driver.switchTo()框架(0);参考帧a和
driver.switchTo()框架(1)。访问帧B。
I'm successfully able to use driver.switchTo().frame(0); to refer to frame a and driver.switchTo().frame(1); to access frame b.
这篇关于硒2 - 焦点切换到不具有名称/ ID帧的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!