Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/neo4j/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 如何使用selenium将文本放入文本字段?_Python_Python 3.x_Selenium - Fatal编程技术网

Python 如何使用selenium将文本放入文本字段?

Python 如何使用selenium将文本放入文本字段?,python,python-3.x,selenium,Python,Python 3.x,Selenium,我正在使用selenium 2.46.0和python 3.4 我想将字符串“Hello,world!”放入textfield以创建新字母。 我这样做对吗?我尝试切换框架并找到合适的元素将文本放入其中。 我的代码: selenium.common.exceptions.nosucheElement 异常:消息:无法定位元素:{“方法”:“id”,“选择器”:“compose_462_Composeditor_ifr”} 我试过: iframe = browser.find_elements_by

我正在使用selenium 2.46.0和python 3.4 我想将字符串“Hello,world!”放入textfield以创建新字母。 我这样做对吗?我尝试切换框架并找到合适的元素将文本放入其中。 我的代码:

selenium.common.exceptions.nosucheElement 异常:消息:无法定位元素:{“方法”:“id”,“选择器”:“compose_462_Composeditor_ifr”}

我试过:

iframe = browser.find_elements_by_tag_name('iframe')[frameindex]
browser.switch_to_frame(iframe)
browser.find_element_by_css_selector('body.tinymce').send_keys('hoo')
但这没有帮助

我添加了一个树的屏幕截图:

该元素的id是动态生成的!尝试以下方法:

browser.switch_to_frame(browser.find_element_by_xpath('//frame[contains(@id, "composeEditor_ifr")]'))

SiKing,嗨,我试着用它。但这并没有起到任何作用
browser.switch_to_frame(browser.find_element_by_xpath('//frame[contains(@id, "composeEditor_ifr")]'))