【发布时间】:2016-05-04 20:58:50
【问题描述】:
我正在尝试切换到允许我输入一些单词的框架。
HTML:
<iframe style="height: 170px; width: 407px;">
#document
<html webdriver="true">
<head></head>
<body>
<br _editor_node="TRUE"</br>
</body>
</html>
</iframe>
我尝试的第一个代码:
driver.switch_to_frame(driver.find_element_by_tag_name('iframe'))
driver.find_element_by_css_selector('br[_moz_editor_bogus_node="TRUE"]').send_keys('hi')
我尝试的第二个代码:
for handle in driver.window_handles:
driver.switch_to.window(handle)
driver.switch_to_frame(driver.find_element_by_tag_name('iframe'))
driver.find_element_by_css_selector('br[_moz_editor_bogus_node="TRUE"]')
我的错误:
NoSuchElementException:消息:无法找到元素:{“method”:“css 选择器","选择器":"br[_moz_editor_bogus_node=\"TRUE\"]"} 堆栈跟踪:
有没有办法按样式切换到框架?
这不起作用
driver.switch_to_frame(driver.find_element_by_css_selector('iframe[style="height:.177px;.width.407px;"]'))
【问题讨论】: