我如何在iframe中的端到端测试量角器添加文本 [英] How i add text in iframe in e2e testing Protractor
本文介绍了我如何在iframe中的端到端测试量角器添加文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我如何p标签添加文字?
< DIV ID =cke_1_contents级=cke_contents cke_reset角色=presentation的风格=高度:350像素;><跨度ID = cke_44级=cke_voice_label>的帮助和LT preSS ALT 0; / SPAN>
< IFRAME类=cke_wysiwyg_frame cke_resetFRAMEBORDER =0SRC =的风格=宽度:100%;身高:100%;标题=富文本编辑器,editor2ARIA-describedby的=cke_106的tabindex =0ALLOWTRANSPARENCY =真>
< HTML LANG =ENDIR =升>
< HEAD>
<车身类=cke_editable cke_editable_themed cke_contents_ltr cke_show_bordersCONTENTEDITABLE =真正的拼写检查=真>
&所述p为H.;
< BR型=_ MOZ>
&所述; / P>
< /身体GT;
< / HTML>
< / IFRAME>
< / DIV>
我用这个code,但在给予错误
VAR P =元素(by.css('cke_editable第'));
p.sendKeys(这是一个peragraph标签');
解决方案
您需要切换到iframe的页面上下文做到这一点:
browser.switchTo()。框架($('。cke_wysiwyg_frame'))变种p值=元件(by.css('cke_editable第'));
p.sendKeys(这是一个peragraph标签');//切换回父页面上下文
browser.switchTo()。defaultContent()
how i add text in p tag?
<div id="cke_1_contents" class="cke_contents cke_reset" role="presentation" style="height: 350px;"><span id="cke_44" class="cke_voice_label">Press ALT 0 for help</span>
<iframe class="cke_wysiwyg_frame cke_reset" frameborder="0" src="" style="width: 100%; height: 100%;" title="Rich Text Editor, editor2" aria-describedby="cke_106" tabindex="0" allowtransparency="true">
<html lang="en" dir="ltr">
<head>
<body class="cke_editable cke_editable_themed cke_contents_ltr cke_show_borders" contenteditable="true" spellcheck="true">
<p>
<br type="_moz">
</p>
</body>
</html>
</iframe>
</div>
i use this code but the give error
var p = element(by.css('.cke_editable p'));
p.sendKeys('This is a peragraph tag');
解决方案
You'll need to switch to the iframe's page context to do this:
browser.switchTo().frame($('.cke_wysiwyg_frame'))
var p = element(by.css('.cke_editable p'));
p.sendKeys('This is a peragraph tag');
// switch back to the "parent page" context
browser.switchTo().defaultContent()
这篇关于我如何在iframe中的端到端测试量角器添加文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文