美文网首页
Python webdriver 定位frameset中的fra

Python webdriver 定位frameset中的fra

作者: 我不喜欢吃苹果 | 来源:发表于2017-12-01 16:55 被阅读0次

在自动化测试中涉及到frame跳转时,总会出现元素定位不到的问题,

假如我们已经定位到name='Top'中,现在我们要去定位name='Menu',有三种解决方案:

1.使用switch_to.parent_frame(),相当于跳转到上一级frameset

self.driver.switch_to.parent_frame()

driver.switch_to_frame("Menu")

2.使用swtich_to_default_content(),相当于跳转到最外层页面

driver.switch_to_default_content()

#driver.switch_to.default_content()

driver.switch_to_frame("Menu")

3.先定位到同一级的frameset中,再定位frame(注:该页面无法操作)

因为本页面frameset没有id或name,如果有id或name为content,可采用下述方法。

frameset=driver.find_element_by_id("content")

frame=frameset.find_element_by_name("Menu")

driver.switch_to_frame(frame)

相关文章

网友评论

      本文标题:Python webdriver 定位frameset中的fra

      本文链接:https://www.haomeiwen.com/subject/aeydbxtx.html