错误切换到iframe selenium python [英] error switching to iframe selenium python

查看:378
本文介绍了错误切换到iframe selenium python的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

目前我正在尝试切换到iframe / fancybox,但我收到以下错误:

Currently I'm attempting to switch to iframe/fancybox, but i'm getting the following error:

line 237, in check_response raise exception_class
(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: 
Message: unknown error: missing 'ELEMENT'

这就是我找到iframe的方式:

This is how I'm locating the iframe:

_iframe_ = {"by": By.XPATH, "value": "//iframe[@class='fancybox-iframe' and starts-with(@id,'fancybox-frame') and contains(@src,'/reminder/add/relation/')]"}


 def __init__(self, driver):
        super(BasePage, self).__init__()
        self.driver = drive
        self.driver.switch_to.frame(self._iframe_)

iframe名称是:

iframe name is:

fancybox-frame1518441842751" 

html:

  <iframe id="fancybox-frame1518443041369" name="fancybox-frame1518443041369" class="fancybox-iframe" frameborder="0" vspace="0" hspace="0" webkitallowfullscreen="" mozallowfullscreen="" allowfullscreen="" scrolling="auto" src="/reminder/add/relation/58048" kwframeid="1"></iframe>


推荐答案

识别< iframe> 正确地,您必须更改定位器策略,如下所示:

To identify the <iframe> properly you have to change the Locator Strategy as follows :

_iframe_ = {"by": By.XPATH, "value": "//iframe[@class='fancybox-iframe' and starts-with(@id,'fancybox-frame') and contains(@src,'/reminder/add/relation/')]"}

 def __init__(self, driver):
    super(BasePage, self).__init__()
    self.driver = driver
    WebDriverWait(driver, 10).until(EC.frame_to_be_available_and_switch_to_it((self._iframe_)))

这篇关于错误切换到iframe selenium python的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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