如何切换到iFrame,在Selenium中不起作用 [英] How to switch to iFrame, not working in Selenium

查看:282
本文介绍了如何切换到iFrame,在Selenium中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在iframe中单击一个对象,但是由于某种原因我无法切换框架.

I am trying to click on an object within the iframe, but I can't switch frames for some reason.

这是我用来切换帧的代码:

This is the code that I am using to switch frames:

driver.switch_to.frame(frame_reference=driver.find_elements_by_xpath('//* 
[@id="practice_schedule"]'))

这是HTML路径:

This is the HTML path:

有解决方案吗?

推荐答案

.find_elements_by_xpath返回列表,从其中删除s,您想要的是.find_element_by_xpath选择第一个元素.

.find_elements_by_xpath return list, remove s from it, what you want is .find_element_by_xpath to select first element.

这篇关于如何切换到iFrame,在Selenium中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆