TA的每日心情 | 衰 2020-12-9 10:21 |
---|
签到天数: 7 天 连续签到: 1 天 [LV.3]测试连长
|
建议尝试一下这个方法:
目前Selenium2Library没有可以利用index进行定位的,所以需要自己新增个方法进行定位,在Python 2.7版本下面,打开C:\Python27\Lib\site-packages\SeleniumLibrary\keywords,找到frames.py文件,在select_frame方法下面新增一个方法:
@keyword
def select_frame_by_index(self, locator, index):
"""Sets frame identified by 'locator' as current frame ,
if 'locator' is not unique, use index Key attributes for frames are 'id' and 'name'.
See 'introduction' for details about locating elements.
Example:
| select_frame_by_index | tag=iframe | 1 |
"""
self.info("Selecting frame '%s'." % locator)
elements = self.find_elements(locator)
element = elements[int(index)]
self.driver.switch_to.frame(element)
此时在RobotFramework可以通过如下方式选择frame
select frame by index
|
|