Python Selenium在iframe窗口中找不到元素

时间:2017-05-15 06:51:46

标签: python selenium iframe selenium-chromedriver

Selenium能够在iframe中找到另一个元素。请参阅以下代码:

# Switch to iframe window    
browser.switch_to.frame("edit-page-body_ifr")
# Select the text
text_box = browser.find_element_by_id('tinymce')
text_box.send_keys(Keys.COMMAND, 'a')

但是找不到这个元素:

browser.find_element_by_id('edit-page-body_fontsizeselect_text').click()

此元素的HTML代码:

<a id="edit-page-body_fontsizeselect_text" tabindex="-1" href="javascript:;" class="mceText mceTitle" onclick="return false;" onmousedown="return false;">12</a>

错误代码:

selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"id","selector":"edit-page-body_fontsizeselect_text"}

Element I'm trying to find.

0 个答案:

没有答案