我无法使用'输入文字输入文字'关键字,对于放置在框架内的texteditor体...能够用按键关键字进行。
Select Frame editor_ifr
sleep 5
${1} Get Text //*[@id='tinymce']/p
Press Key //*[@id='tinymce']/p abcde
Comment Run Keyword And Ignore Error Input Text //*[@id='tinymce']/p Test
Comment ${tst} Run Keyword And Ignore Error Execute Javascript tinyMCE.activeEditor.setContent('Your text')
Comment Run Keyword And Ignore Error Input Text + "</p>'") Test
${1} Get Text //*[@id='tinymce']/p
答案 0 :(得分:0)
我通过javascript为phantomjs和selenium 输入文字 关键字两种方式输入文字。
# Select TinyMCE iframe for the instructions field.
Select Frame id=tinymceIframe
sleep 5
# Input Text only works with browsers for tinymce. It's not working for phantomjs because the field in
# TinyMCE is a contenteditable element and not an input or textarea field.
Input Text id=tinymce This is works
# To side step the contenteditable field, for phantomjs, the content of the tinyMCE iframe body will be
# changed via JavaScript, if the browser is set to phantomjs
Run keyword if '${BROWSER}' == 'phantomjs' Execute Javascript document.getElementById("tinymce").innerHTML='This is works';
# Ensure tinymce reflects this change in the text editor
Execute Javascript function selectElementContents(el) {var range = document.createRange(); range.selectNodeContents(el); var sel = window.getSelection(); sel.removeAllRanges(); sel.addRange(range);} var el = document.getElementById("tinymce"); selectElementContents(el);
# Exit the TinyMCE iframe
Unselect Frame