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