1 def switch_to_frame(self, frame_reference):
2 """
3 Switches focus to the specified frame, by index, name, or webelement.
4
5 :Args:
6 - frame_reference: The name of the window to switch to, an integer representing the index,
7 or a webelement that is an (i)frame to switch to.
8
9 :Usage:
10 driver.switch_to_frame('frame_name')
11 driver.switch_to_frame(1)
12 driver.switch_to_frame(driver.find_elements_by_tag_name("iframe")[0])
13 """
14 self.execute(Command.SWITCH_TO_FRAME, {'id': frame_reference})
可知,参数frame_reference有3种形式。对于无id的frame,即可通过后2种参数,定位到此frame。相对来说,后2种参数更像是通过一个页面中所有frame的“相对位置”,来定位具体某一个frame;而第1种参数则是通过绝对的”名“来定位。