我如何在标签中端到端测试角量角器添加文本 [英] How i add text in a tag in e2e testing Angular Protractor

查看:193
本文介绍了我如何在标签中端到端测试角量角器添加文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我怎么在

标签中添加量角器内容端到端测试

 < HTML LANG =ENDIR =升>
 < HEAD>
  <车身类=cke_editable cke_editable_themed cke_contents_ltr cke_show_bordersCONTENTEDITABLE =真正的拼写检查=真>
   &所述p为H.;
     < BR型=_ MOZ>
   &所述; / P>
 < /身体GT;
< / HTML>

我试试这个,但是这是行不通的。

  VAR P =元素(by.css('cke_editable第'));
p.sendKeys(这是一个peragraph标签');


解决方案

首先,它是在这种情况下,可编辑的身体 - 发送键吧:

  VAR体=元素(by.css('body.cke_editable'));
body.sendKeys('这是一个段落标记);

有一个更大的问题是,虽然,因为这是一个的 CKEDITOR - 它通常嵌入在 IFRAME 的。这实际上是重要的,我们 - 我们需要让webdriver的知道我们想要的切换到上下文中的 IFRAME

  browser.switchTo()帧(件(by.css(iframe.cke_wysiwyg_frame)))。变种体=元件(by.css('body.cke_editable'));
body.sendKeys('这是一个段落标记);

how i add content in

tag for e2e testing in protractor

<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>

i try this but this is not working

var p = element(by.css('.cke_editable p'));
p.sendKeys('This is a peragraph tag');

解决方案

First of all, it is the body that's editable in this case - send keys to it:

var body = element(by.css('body.cke_editable'));
body.sendKeys('This is a paragraph tag');

A bigger problem though is that, since this is a CKeditor - it's usually embedded in an iframe. This is actually important for us - we need to let the webdriver know that we want to switch into the context of the iframe:

browser.switchTo().frame(element(by.css("iframe.cke_wysiwyg_frame")));

var body = element(by.css('body.cke_editable'));
body.sendKeys('This is a paragraph tag');

这篇关于我如何在标签中端到端测试角量角器添加文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆