【问题标题】:How to switch to iFrame, not working in Selenium如何切换到 iFrame,在 Selenium 中不起作用
【发布时间】:2018-12-05 07:21:16
【问题描述】:

我试图点击 iframe 中的一个对象,但由于某种原因我无法切换帧。

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

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

这是 HTML 路径:

有什么解决办法吗?

【问题讨论】:

  • 为什么你认为它没有切换?当您尝试此代码时会发生什么?

标签: python selenium xpath iframe selenium-chromedriver


【解决方案1】:

.find_elements_by_xpath返回列表,将s去掉,你要.find_element_by_xpath选择第一个元素。

【讨论】:

    猜你喜欢
    • 2014-06-11
    • 1970-01-01
    • 2021-11-14
    • 1970-01-01
    • 2015-02-11
    • 2023-03-07
    • 1970-01-01
    • 1970-01-01
    • 2021-06-19
    相关资源
    最近更新 更多